Search code examples
jbossjpa-2.0dom4j

What's the solution to the JBoss AS 7.1 dom4j Exception?


I've got RESTful web services that I deploy in a .war file in JBoss AS 7.1. So far so good. Now I'm adding a .jar file with JPA 2.0 Entities. When I deploy the .war with the .jar file with the JPA Entities included I get this Exception at deploy time:

org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory

This problem is posted numerous times all over the web and there are about half as many suggested solutions but none of them work.

There is no dom4j.jar in my archive. My Hibernate 4.0 dependencies are all <scope>provided</scope>. None of the .jar files included in my .war file have any dom4j classes in them.

Does anyone know what causes this with JBoss 7.1 and what the solution is?

Thanks.


Solution

  • The dom4j Exception was caused by having an incorrect port number in the in standalone.xml. Instead of throwing a meaningful exception JBoss threw the meaningless exception about dom4j.

    After correcting the port number, I tried to reproduce the error by undeploying the archive, shutting down JBoss and setting the port number back to the incorrect port number. When I deployed and enabled the archive this time JBoss showed an Exception that it could not get a managed connection for the datasource. The meaningless exception gets replaced by meaningful exception after the first successful deployment of the archive with the correct .

    A longer thread about this process is here.