How to declare classloading dependencies between deployments in JBoss EAP 7 / 6

Solution Verified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 7.x
    • 6.x

Issue

  • How to declare classloading dependencies between deployments in JBoss EAP 6 and EAP 7.
  • There are 2 ejb packages, one jar depends of the another. Using the manifest.mf or jboss-deployment-structure.xml, it does not work. How can this be done?

Resolution

Deployments have a JBoss Module which contains their classes which is created based on the name of the deployment such as if you deploy an ear containing a war:

my.ear
 - my.war
 - my-ejb.jar
 - lib
   -- my-util.jar

Then there would be a module name for the ear that would be: deployment.my.ear
And the module name for the war in the ear would be: deployment.my.ear.my.war
And the module name for the ejb in the ear would be: deployment.my.ear.my-ejb.jar

If you have a third deployment (app.ear), which needs to load classes contained in jars in my.ear/lib for example, it would just include a dependency on deployment.my.ear via the jboss-deployment-structure.xml such as:

app.ear/META-INF/jboss-deployment-structure.xml

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
  <deployment>
    <dependencies>
      <module name="deployment.my.ear" export="true"/>
    </dependencies>
  </deployment>
</jboss-deployment-structure>

To have visibility to the ear's sub deployments, a dependnecy would be specified on its module name such as:

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
  <deployment>
    <dependencies>
      <!-- depending on the my.war in my.ear -->
      <module name="deployment.my.ear.my.war" export="true"/>
      <!-- depending on the my-ejb.jar in my.ear -->
      <module name="deployment.my.ear.my-ejb.jar" export="true"/>
    </dependencies>
  </deployment>
</jboss-deployment-structure>

Setting export=true allows any subdeployments of app.ear to also see the deployment.my.ear classes.

The classloading dependency will ensure that when app.ear is being deployed that the classes in my.ear are available for it to load, however this does not ensure that my.ear has been fully deployed and its services started (such as EJBs, Wars, etc...). See 1 for information on service dependencies and 2 3 for general full deployment dependencies.

Deployments can also specify the dependencies in the META-INF/MANIFEST.MF, though it is recommended to use the jboss-deployment-structure.xml to specify the dependencies as it is easier to locate the configuration when debugging.

Example META-INF/MANIFEST.MF

Dependencies: org.javassist export,org.apache.velocity export services,org.antlr,deployment.ojdbc6.jar"

Related Solutions

Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.