Unable to exclude JBoss-provided module
pstackle Nov 19, 2011 12:25 AMI am having trouble loading the correct version of a class when deploying my EAR file in JBoss AS 7.0.2. My EAR file contains 5 WAR files and 1 JAR file. I have a version of the xml security library that is older than the one included in the jboss/modules directory. My older version of the library is in the EAR's lib directory.
{code}myapp.ear
|
|--- web1.war
|
|--- web2.war
|
|--- web3.war
|
|--- web4.war
|
|--- web5.war
|
|--- ejb1.jar
|
|--- lib
|
|--- xmlsec-old.jar
|
|--- META-INF
|
|--- jboss-deployment-structure.xml
{code}
I am attempting to load the version of a class out of my version of the library (xmlsec-old.jar) from a servlet in web1.war, but the class's classloader indicates that it loaded the class from the jboss/modules version of the library (jboss/modules/org/apache/santuario/xmlsec)
{code}
ClassLoader cl = org.apache.xml.security.Init.class.getClassLoader();
System.out.println("Init's ClassLoader: " + cl.toString());
{code}
Output:
Init's ClassLoader: ModuleClassLoader for Module "org.apache.santuario.xmlsec:main" from local module loader @624b035d (roots: /home/<username>/dev/servers/jboss-as-7.0.2/modules)
Output when I print out the servlet's ClassLoader:
StartupServlet ClassLoader: ModuleClassLoader for Module "deployment.myapp.ear.web1.war:main" from Service Module Loader
Based on what I read about JBoss AS 7 class loading (https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7)
I am attempting to use the following xml in my jboss-deployment-structure.xml file in my EAR's META-INF directory.
{code:xml}
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.apache.santuario.xmlsec" />
</exclusions>
<dependencies>
<module name="deployment.xmlsec" />
<module name="system">
<imports>
<include-set>
<path name="sun/security/x509" />
</include-set>
<exclude-set>
<path name="org/apache/xml/security" />
</exclude-set>
</imports>
</module>
</dependencies>
</deployment>
<module name="deployment.xmlsec">
<resources>
<resource-root path="xmlsec-old.jar" />
</resources>
</module>
</jboss-deployment-structure>
{code}
My theory is that I am indicating that I want to exclude the santuario.xmlsec module and depend on a new module that I create using my xmlsec-old.jar file. Despite trying a number of different combinations of things, I have been unable to load the correct version of the class. Can anyone point out what I am doing wrong or what else I could try? Thank you.