Hi, i have two ears deployed on jboss with proper classloaders isolation settings. When seam bean call spring beans which make some queries on database everything works fine, but when spring quartz job bean is invoked and execute tries to execute database queries then there is a problem because spring tries too use hibernate jar from other ear and exception is thrown! It is clearily spring classloader isolation problem. Did anyone meet such a problem? How to ensure isolation?
I'll bet the Hibernate JAR that SEAM is using comes from the JBOSS class loader, which is called before any EAR class loader. This is happening because SEAM is bundled in with JBOSS.
Spring in the EAR is using a different version of the Hibernate JAR or its dependencies, so you get a conflict.
You'd either have to remove the Hibernate JAR from JBOSS so it was no longer visible to the app server class loader, but that would probably break SEAM.
You might see if JBOSS has any way to tell the app server to prefer app level JARs to server JARs in the EAR configuration.
Assuming JBoss 4.x, then in the deploy/ear-deployer.xml
file, make sure you have classloader isolation enabled, e.g.
<server>
<mbean code="org.jboss.deployment.EARDeployer" name="jboss.j2ee:service=EARDeployer">
<attribute name="Isolated">true</attribute>
<attribute name="CallByValue">false</attribute>
<attribute name="EnablelibDirectoryByDefault">true</attribute>
</mbean>
</server>
This will prevent classes in one EAR from being visible to another. For some reason, the default is to have Isolation=false
.
This may be sufficient. However, you may also have to add a jboss-app.xml
file in the EAR's META-INF
directory, containing something like this:
<jboss-app>
<loader-repository>MyCompany:loader=MyApplication</loader-repository>
</jboss-app>
I'm not sure that this does or what uses it, but in some cases it seems to strengthen the isolation between EARs.