Friday, August 22, 2008

JBoss EAR Classloading

Jboss follows the standard J2EE 1.4 spec that all Jar resources in the EAR must be specified as a
<module>
<java>lib/jarfile.jar</java>
</module>
entry in the META-INF/application.xml. So if its not specified in this file, JBoss is blind to it during runtime.

The other issue is the embedded Tomcat cannot see out to the enclosing ear file to retrieve classes until you change a setting in JBoss. You must set the UseJbossWebLoader property to true in deploy/jbossweb-tomcat5.5/META-INF/jboss-service.xml. Once you do this, all the jars that you've specified in your application.xml are visible to the underlying war file.

We had a properties file that existed in WEB-INF/classes/app.properties Using the JbossWebLoader=true, this file was not visible to the class loader. Moving the file to WEB-INF/classes/resources/app.properties, made the file visible and the calling application, in this case a jsf change was made to

There also exists the possibilty of using JbossWebLoader=false, then creating a META-INF/MANIFEST.MF entry for Class-Path: in the war archive.
Class-Path: jarfile.jar
This entry will explictly tell the web archive exactlly what jars it needs on its classpath from the upper level ear archive.

To study more about jboss classloading, visit http://wiki.jboss.org/wiki/ClassLoading

1 comment: