AS 7: Excluding a container library from WAR classpath
mattj6502 Jul 25, 2013 10:49 AMHello, I've been digging on this one for several hours to no avail. The problem I'm having is that I have a legacy WAR that I need to deploy within AS 7.1, and the WAR is a Cocoon-based app. Cocoon (apparently) uses Eclipse JDT to do its thing, but AS 7 is exposing a version of JDT (via the "org.jboss.as.web" module) which is not compatible with the version of Cocoon in the WAR. It's the typical classloader nuttiness that we've all been dealing with for a decade or more now--a NoSuchMethodError in this particular case. But the cause is the classic "wrong version of library on the classpath" issue.
For the life of me, I cannot figure out how to get AS 7 to keep its version of JDT to itself and not expose it to the web app (which is deployed as a standalone WAR--it is not packaged in an EAR file.)
I have tried many, many different combinations of things in jboss-deployment-structure.xml, using the 1.2 schema. The documentation at https://docs.jboss.org/author/display/AS71/Class+Loading+in+AS7 seems to imply that something like this would be correct (derived from the chuck on the "org.javasisst" module in the example jboss-deployment-structure.xml file):
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclusions>
<module name="org.jboss.as.web"/>
</exclusions>
<dependencies>
<module name="deployment.customjbossweb"/>
</dependencies>
</deployment>
<module name="deployment.customjbossweb">
<dependencies>
<module name="org.jboss.as.web">
<imports>
<exclude path="/org/eclipse/jdt/**"/>
<include path="/**"/>
</imports>
</module>
</dependencies>
</module>
</jboss-deployment-structure>
The "org.javasisst" module in the example does the opposite of what I'm trying to do--pokes a container package through to the app, whereas I want to hide a container package from the app--but it seems sensical:
- Exclude the standard module.
- Derive a custom module from the standard module, but exclude some classes from import.
- Depend on the custom module.
In the end, the only part of this that appears to work is the exclusion: I get ClassNotFoundExceptions referencing org.apache.jasper, org.apache.catalina, etc. on startup. I'm guessing this means I've lost the entire cast of packages and classes that come with the "org.jboss.as.web" module. Kind of hard to stand up a web app without those classes...
I have also done the typical trial-and-error stuff. Got rid of the exclusion altogether and tried an explicit dependency on the "org.jboss.as.web" module, with an appropriate nested <imports> structure, to no avail.
I can work around this my modifying the module.xml file for the "org.jboss.as.web" module, at the server config/implementation level, and excluding "org/eclipse/jdt" from export. But this is obviously not an ideal solution. I'm essentially modifying the server itself to work around an application issue.
For the life of me, I can't figure out why JDT is exposed through web app classloaders in the first place. But I don't know all of the issues involved in implementing an application server.
Any hints? Class loading seems to be a soft spot in the documentation/knowledge base surrounding AS 7 at the moment..