0

I've been struggling with this one for a few days now, hopefully someone can help.

I'm getting the following error when my application tries to build my Hibernate3 SessionFactory:

    ...
    org.hibernate.HibernateException: Could not parse configuration: hibernate.cfg.xml
    ...
    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
    ...

Below is my /WEB-INF/jboss-web.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <jboss-web>
        <loader-repository>some.unique.package.name:archive=lvs.war
                <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
        </loader-repository>
    </jboss-web>

Hibernate works fine in my unit tests, it's only when I deploy it to the test server that this happens.

From what I've found, this appears to be happening because jboss already has a copy of dom4j.

No I can't remove dom4j from my project, web-apps on the server it will be hosted on are expected to use all their own jars.

anTrodaire
  • 93
  • 9
  • Can you up/down-grade your jdom to the jboss' version? – serg.nechaev Aug 17 '16 at 03:11
  • @serg.nechaev That may work in the short term on my development server, but long term it doesn't help. As I said in the question, web-apps on the production server are expected to use all their own jars. – anTrodaire Aug 17 '16 at 15:05

1 Answers1

0

Try to change / check value for your server configuration.

In server/xxx/deploy/jboss-web.deployer/META-INF/jboss-service.xml
there are two attributes to try

  • Java2ClassLoadingCompliance
  • UseJbossWebLoader

Both are boolean values and control some class loader behaviour.

HTH.

Ole V.V.
  • 81,772
  • 15
  • 137
  • 161
Greg Henry
  • 61
  • 6
  • I can't make any changes to the server. It's shared by a few offices in the region, and completely beyond my control. – anTrodaire Jan 26 '17 at 17:54