JBoss 7 module hell!
dmen May 16, 2013 5:24 AMWe have a web application that uses, among others, hibernate and dom4j. The respective jars are bundled in WEB-INF/lib.
I have been struggling to deploy on JBoss 7.1 due to module classloading problems. This is interesting because the marketing sales pitch is "No more jar hell!". No matter what I do, JBoss tries to load its own builtin jars and I end up with either ClassNotFoundException or class cast exceptions. Here is the current WEB-INF/jboss-deployment-structure.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.jboss.logging" />
<module name="org.apache.commons.logging" />
<module name="org.apache.log4j" />
<module name="org.slf4j" />
<module name="org.hibernate" />
<module name="org.hibernate.envers" />
<module name="org.hibernate.validator" />
<module name="asm.asm" />
<module name="javax.api" />
<module name="javax.persistence.api" />
<module name="javax.transaction.api" />
<module name="javax.validation.api" />
<module name="org.antlr" />
<module name="org.apache.commons.collections" />
<module name="org.dom4j" />
<module name="org.infinispan" />
<module name="org.javassist" />
<module name="org.jboss.as.jpa" />
<module name="org.jboss.as.jpa.hibernate" />
</exclusions>
</deployment>
</jboss-deployment-structure>
Note, I have started by excluding only org.hibernate and org.dom4j and ended, as you can see, tried excluding almost everything. No luck however. Here is the exception with this config:
11:48:06,738 INFO [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-6) HHH000204: Processing PersistenceUnitInfo [
name: xyz
...]
11:48:06,786 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC00001: Failed to start service jboss.persistenceunit."xyz-view.war#xyz": org.jboss.msc.service.StartException in service jboss.persistenceunit."xyz-view.war#xyz": Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_21]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_21]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_21]
Caused by: org.hibernate.InvalidMappingException: Unable to read XML
at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:106)
at org.hibernate.ejb.Ejb3Configuration.addXMLEntities(Ejb3Configuration.java:734)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:603)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
... 3 more
Caused by: org.dom4j.DocumentException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory Nested exception: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:76)
... 10 more
Keep in mind that we are trying to build a portable war bundle. That means it should be deployable without making changes to the app server, i.e. don't want to deal with creating or modifying JBoss specific modules and such.