-
1. Re: The library I use needs original log4j but at the same time I want to use JBoss logging infrastructure
griffin777 Apr 10, 2012 6:36 PM (in response to griffin777)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:
Dependencies: org.apache.log4j
"
I don't add log4j dependency but JBoss still loads it - is it a bug in docs or is it a bug in JBoss?
-
2. Re: The library I use needs original log4j but at the same time I want to use JBoss logging infrastructure
jamezp Apr 13, 2012 1:25 PM (in response to griffin777)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
-
3. Re: The library I use needs original log4j but at the same time I want to use JBoss logging infrastructure
griffin777 Apr 11, 2012 5:46 AM (in response to jamezp)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:
{code:xml}<jboss-deployment-structure>
<deployment>
.......
</deployment>
<module name="deployment.mylib" >
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
<exports>
<include path="com/yyy/mylib/**" />
</exports>
<resources>
<resource-root path="mylib.module/mylib-1.5.0.jar" />
<resource-root path="mylib.module/log4j-1.2.16.jar" />
</resources>
</module>
</jboss-deployment-structure>{code}
-
4. Re: The library I use needs original log4j but at the same time I want to use JBoss logging infrastructure
jamezp Apr 11, 2012 11:34 AM (in response to griffin777)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.
-
5. Re: The library I use needs original log4j but at the same time I want to use JBoss logging infrastructure
griffin777 Apr 12, 2012 5:12 AM (in response to jamezp)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.