3 Replies Latest reply: Jul 31, 2012 5:58 AM by Max Rydahl Andersen RSS

Add jboss-deployment-structure.xml dependencies to Eclipse build path.

beubanks Newbie

Background: I am deploying a dynamic web project to JBoss AS 7.1.1 using Eclipse 4.2 with JBoss Tools 3.3.0 Final. My project's build path includes the JRE System Library, JBoss 7.1 Runtime, and Web App Libraries (the WEB-INF/lib folder). I also have a jboss-deployment-structure.xml file that defines additional module dependencies such as the following:

 

<jboss-deployment-structure>
  <deployment>
    <dependencies>
      <module name="org.slf4j" />
      <module name="org.apache.log4j" />
    </dependencies>
  </deployment>
</jboss-deployment-structure>

 

The problem is, the slf4j and log4j modules are not included in the project's build path. While the server resolves them correctly at runtime because of the jboss-deployment-structure.xml file, Eclipse doesn't include them. So the following declaration in the Java code would result in a build error because org.apache.log4j cannot be resolved to a type:

 

private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(Example.class);

 

The JBoss runtime that the project is using is configured correctly. It points to a valid JBoss directory, and the module dependencies are properly installed in the server.

 

So, is there a way to automatically add the jboss-deployment-structure module dependencies to the Eclipse build path? So far, I've been unable to find a way to do this.

 

I have found a few workarounds, but none of them are ideal, and they seem to completely miss the point of module-based dependencies:

  1. Customize the Default Classpath Entries for the server runtime. This is not acceptable because it must be done in each developer's workspace – and possibly per project since projects may have different, conflicting dependencies.
  2. Add the libraries to WEB-INF/lib. This is not acceptable because it defeats the purpose of server modules.

  3. Add the libraries to a user library for the project. This could work, but it's very inconvenient, because each developer on the team would have to add the jars to the user libraries in their workspaces.

 

Have I missed a solution to this problem that JBoss Tools already provides? Or, does anyone have any other ideas?

 

Thanks in advance,

Bron