Tuesday, July 3, 2012

JBoss 7 - 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

Simple solution to fix this issue:


If you do not want to read the above URL, which is really not giving the straight forward solution:
1 - Open {your war}/META-INF/MANIFEST.MF
2 - Add this line at the end - Dependencies: org.dom4j export


You do not need to do any of the following:
1 - jboss-deployment-structure.xml - exclussions
2 - Adding subsystem to include org.dom4j as global modules
3 - Remove your dom4j-1.6.1.jar from your WEB-INF/lib directory

Most of the time you hit this problem when you try to deploy a war that has hibernate 4 included in it. In this case you may want to do the following for JBoss 7:
To your persistence.xml add the following properties, which is not need for tomcat (assuming you are using oracle > 10g).
 <properties >
    <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/ >
    <property name="hibernate.listeners.envers.autoRegister" value="false"/ >
</properties >

No comments: