Yesterday night I had spent an hour or so tracking down a bug that has been bothering me for a while. The effect of this bug is that projects created with the m2eclipse plugin seem to be missing some important metadata required by the WTP plugins. As a result references to other projects (in workspace) do not show up as JavaEE (J2EE) module dependencies or sometimes even the project properties dialog for JavaEE module dependencies only shows an error. I had analysed this bug a while ago already but never documented this, some more investigation is still required to figure out what causes this missing metadata and report it to the m2eclipse developers.

Anyway here is how to fix it. Let’s say we have a web project A and a utility project B. You face the situation that project B does not show up as JavaEE module dependency. Open B in the navigator view (so you can see all the metadata files .project, .settings/… etc.). Look for a file .settings/org.eclipse.wst.common.component! Does it exist? If no just create it, its contents should be like

1
2
3
4
5
6
7
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
    <wb-module deploy-name="PROJECTNAME">
        <wb-resource deploy-path="/" source-path="/src/main/java"/>
        <wb-resource deploy-path="/" source-path="/src/test/java"/>
    </wb-module>
</project-modules>

Next check the .project file

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
  <name>PROJECTNAME</name>
  <comment></comment>
  <projects>
  </projects>
  <buildSpec>
      <buildCommand>
          <name>org.eclipse.wst.common.project.facet.core.builder</name>
          <arguments>
          </arguments>
      </buildCommand>
      <buildCommand>
          <name>org.eclipse.jdt.core.javabuilder</name>
          <arguments>
          </arguments>
      </buildCommand>
      <buildCommand>
          <name>org.maven.ide.eclipse.maven2Builder</name>
          <arguments>
          </arguments>
      </buildCommand>
      <buildCommand>
          <name>org.eclipse.wst.validation.validationbuilder</name>
          <arguments>
          </arguments>
      </buildCommand>
  </buildSpec>
  <natures>
      <nature>org.eclipse.jdt.core.javanature</nature>
      <nature>org.maven.ide.eclipse.maven2Nature</nature>
      <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
      <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
      <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
  </natures>
</projectDescription>

In my case the file was missing some builders (should not be relevant for the bug)

  • org.maven.ide.eclipse.maven2Builder
  • org.eclipse.wst.validation.validationbuilder

and some natures (these really hurt)

  • org.eclipse.wst.common.modulecore.ModuleCoreNature
  • org.eclipse.jem.workbench.JavaEMFNature

Comments