Q: I set useJBossWebClassLoader=true in war-deployers-jboss-beans.xml but it doesn't work?
A: This parameter is no longer used in JBoss5. The "WarDeployer" no longer handles the classloading configuration for web apps. In fact, all war classloaders in JBoss5 are jboss classloaders.
What you need to do is change war's classloading configuration. There are at least two ways to do this:
1) Remove the WARClassLoaderDeployer
The WARClassLoaderDeployer automatically implements to the spec defined classloading rules for wars. That is each war gets its own scoped classloading domain where its classes are not visible to other applications (or any ear it is a part of) and the war's classes are looked at first. If you comment out the "WarClassLoaderDeployer" in deployers/jbossweb.deploy/META-INF/war-deployers-jboss-beans.xml then the war classloading will behave like any other deployer.
2) Define the classloading rules explicitly for the war
If you add a WEB-INF/jboss-classloading.xml with the following content to the war. Then you can define exactly how the war's classloader gets constructed. In this case, we put the war's classloader in the "DefaultDomain" which is shared with all other applications that don't define their
own domain. We also choose to look at all other classes exported by other applications "import-all" and to expose all our classes to other classes "export-all".
<?xml version="1.0" encoding="UTF-8"?>
<classloading xmlns="urn:jboss:classloading:1.0"
name="mywar.war"
domain="DefaultDomain"
<!-- A hack to make this classloader a top-level classloader
The actual value is ignored since DefaultDomain
already exists.
-->
parent-domain="Ignored"
export-all="NON_EMPTY"
import-all="true">
</classloading>
Note: there is an issue (see hack) with this 2nd approach for wars that are sub-deployments.
The fix is wip, JIRAs to follow:
* https://jira.jboss.org/jira/browse/JBDEPLOY-222
* https://jira.jboss.org/jira/browse/JBCL-125
Comments