I found in the AS71 docs that:
"If you are creating a deployment which uses Apache Log4j, you must add a dependency on the appropriate module. The Log4j module is called "org.apache.log4j", so your MANIFEST.MF should look like this:
I don't add log4j dependency but JBoss still loads it - is it a bug in docs or is it a bug in JBoss?
No it's not a bug. Deployments automatically get log4j, slf4j, commons-logging and JBoss logging. If you need your own version of log4j you need to exclude the one provided by the server. You can do this with a jboss-deployment-structure.xml, https://docs.jboss.org/author/display/AS71/Class+Loading+in+AS7#ClassLoadinginAS7-JBossDeploymentStructureFile, that you can place in in the META-INF directory in your EAR.
<jboss-deployment-structure> <deployment> <dependencies> <!-- Exclusions allow you to prevent the server from automatically adding some dependencies --> <exclusions> <module name="org.apache.log4j" /> </exclusions> </dependencies> </deployment> </jboss-deployment-structure>
Message was edited by: James Perkins - Just fixing bad XML
Thanks for replying.
Okay so in this case the documentation has to be updated because it states something diffrent:
https://docs.jboss.org/author/display/AS71/How+do+I+migrate+my+application+from+AS5+or+AS6+to+AS7 says that you need to explicitly add log4j dependency,
https://docs.jboss.org/author/display/AS71/Implicit+module+dependencies+for+deployments do not list log4j as imlicit dependency
Now I would like to exclude log4j as you mentioned, but I would like to exclude it from the custom module not from deployment or subdeplyment - is it possible?
I would like to be able to do something like that:
<module name="deployment.mylib" >
<module name="org.apache.log4j" />
<include path="com/yyy/mylib/**" />
<resource-root path="mylib.module/mylib-1.5.0.jar" />
<resource-root path="mylib.module/log4j-1.2.16.jar" />
Thanks I'll get that documentation updated.
Yes that should be doable. I don't know that you can add the exclusion to the module though. I think it has to be done on the deployment, but I'm not sure on that. If you put log4j and your other library in the /lib directory on your deployment you shouldn't need to defne them in the deployment structure.
According to the schema you cannot add the excustion to the module - which seems to me like a missing important feature. I was able to workaround that by creating fake war deployment (it contains empty web.xml and mylib jar + original log4j jar) and because it is a standard subdeployment I'm able to exclude JBoss log4j implicit dependency.
Another missing feature I noted is the lack of the ability to re-export dependencies from deployments and subdeployments, it is possible to do that for modules.