problem with web app classloader isolation
bubak10 Mar 17, 2011 7:38 PMHi,
I have a problem with my web application classloader isolation.
I would like to have separated classloader for my WAR, which will at first try to load classes from [WAR file]/WEB-INF/lib and [WAR file]/WEB-INF/classes. If it doesn't find the class there, it will delegate the request to it's parent which should be some JBoss default classloader.
I definitely don't want to share libraries with any other application deployed in the JBoss.
Is it even possible?
My Jboss version is jboss-6.0.0
I didn't change any configuration in the default installation.
In WAR file, I've tried these config xmls:
[WAR file]/WEB-INF/jboss-classloading.xml
<?xml version="1.0" encoding="UTF-8"?><classloading xmlns="urn:jboss:classloading:1.0"
name="myapp.war"
domain="myapp.war"
parent-domain="DefaultDomain"
export-all="NON_EMPTY"
import-all="false"
parent-first="false" >
</classloading>
[WAR file]/WEB-INF/jboss-web.xml
<jboss-web>
<class-loading java2ClassLoadingCompliance="false">
<loader-repository>com.myapp:archive=myapp
<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
</loader-repository>
</class-loading>
</jboss-web>
However it doesn't help.
My app ends with this message:
Deployment "vfs:///home/user/soft/jboss-6.0.0.Final/server/default/deploy/myapp.war" is in error due to the following reason(s): java.lang.ClassNotFoundException: 1.0.com.sun.codemodel.JConditional
... of course class 1.0.com.sun.codemodel.JConditional is in one of the jars in the WEB-INF/lib/
And many other applications don't work as well.Problem probably is, that libraries loaded by myapp classloader are shared by other applications so the log is full of these(or similar) error messages:
Deployment "vfs:///home/user/soft/jboss-6.0.0.Final/server/default/deploy/hornetq/jms-ds.xml" is in error due to the following reason(s): java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "javax/transaction/xa/XAResource"
Could you please suggest the working way how to isolate the classloaders as I described above?
Thanks,
Martin