-
Enhancement
-
Resolution: Done
-
Minor
-
None
-
7.0.2.Final
-
None
I deploy an ear with an EJB and a WAR module. In both modules I want to use logging, so I want to add the org.slf4j module to their classpath.
My first attempt to get this done was this simple jboss-deployment-structure.xml file which I placed in the META-INF folder of the EAR.
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.slf4j" />
</dependencies>
</deployment>
</jboss-deployment-structure>
This however, does not get the job done in the case of an EAR though; SLF4J is not on the classpath of either ear module. When I deploy this exact file in a web application that deploys as a war (in the WEB-INF folder), this does work. Of course that makes some sense as the war doesn't have sub-deployments.
In stead, I have to do this:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.slf4j" />
</dependencies>
</deployment>
<sub-deployment name="chipstkpov-ejb.jar">
<dependencies>
<module name="org.slf4j" />
</dependencies>
</sub-deployment>
<sub-deployment name="chipstkpov-web.war">
<dependencies>
<module name="org.slf4j" />
</dependencies>
</sub-deployment>
</jboss-deployment-structure>
Note that the <deployment> section is still needed, if I leave it out the dependency still does not end up on the classpath of the sub-deployments. With this exact setup the EAR deploys just fine.
As I understand from my test results, you need to;
- define the dependencies you want to expose to the classpath in the <modules> section
- per sub-deployment you have to then explicitly add that dependency as well
What I would expect and prefer is that the first example I gave would do exactly the same WITHOUT me having to explicitly name the sub-deployments of the ear in this file. That is duplicate maintenance as any change I make to the build structure (maven poms in my case) I will now have to duplicate in this file.
Note that if I am correct in my findings, it would be very useful if this is documented in the jboss classloading documentation.
https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7