-2

I'm trying to move from wildfly9 to wildfly 10. My code works properly on wildfly9 But when I try to deploy my ejb module on wildfly 10 I get the following error:

 java.lang.ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory

I tried all the options available out there to correct this error but nothing helped me.

Here are the dependencies that i have in my pom

<dependencies>
        <dependency>

            <groupId>za.co.ecommunicate</groupId>
            <artifactId>pl4sms-billing</artifactId>
            <version>1.0-SNAPSHOT</version>

        </dependency>


        <!-- ehcache dependency -->
        <dependency>
            <groupId>net.sf.ehcache</groupId>
            <artifactId>ehcache</artifactId>
            <version>2.9.0</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-ehcache</artifactId>
            <version>5.1.0.Final</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-c3p0</artifactId>
            <version>5.1.0.Final</version>

        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>5.1.0.Final</version>

        </dependency>
        <!-- ehcache dependency -->
        <dependency>
            <groupId>za.co.ecommunicate</groupId>
            <artifactId>pl4sms-persistence</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>



        <!-- dependencies require for test asserts -->
        <!-- <dependency> <groupId>za.co.ecommunicate</groupId> <artifactId>pl4sms-web</artifactId> 
            <version>1.0-SNAPSHOT</version> </dependency> -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.8.13</version>
        </dependency>
        <dependency>
            <groupId>org.apache.openejb</groupId>
            <artifactId>tomee-embedded</artifactId>
            <version>1.0.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>


    </dependencies>

According to the solutions available I have found the the problem is related to hibernate, I have updated hibernate dependencies, changing the scope and also adding dom4j dependency but nothing worked.

The same module gets deployed without any problem on wildfly 9.

Can anybody help me out in resolving this error.

this.user3272243
  • 1,166
  • 2
  • 9
  • 24
kirti
  • 4,499
  • 4
  • 31
  • 60

2 Answers2

1

I have found the solution of my question may be it will help others. i got the solution from this blog.

I added the line in my war's MANIFEST.MF file:

  1. Open {your war}/META-INF/MANIFEST.MF
  2. Add this line at the end - Dependencies: org.dom4j export

and added the following line in persistence.xml:

<property name="hibernate.listeners.envers.autoRegister" value="false"/ >

And it worked for me.

eis
  • 51,991
  • 13
  • 150
  • 199
kirti
  • 4,499
  • 4
  • 31
  • 60
0

You problem is this:

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>5.1.0.Final</version>

    </dependency>

It brings in the old dom4j jar: Reference this ticket: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory.

You either need to remove it, declare it as provided in scope, or not run the application on the Wildfly Server (which is probably not your preferred option).

K.Nicholas
  • 10,956
  • 4
  • 46
  • 66