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

前端 未结 14 950
醉酒成梦
醉酒成梦 2020-11-29 04:25

I have a maven application that works fine in wildfly 8.2, but when Ideployed it in wildfly 10 this error happened:

[2016-02-21 11:22:08,411] Artifact Sarama         


        
相关标签:
14条回答
  • 2020-11-29 05:01

    Had the same problem, but I solved it using the hibernate5 official quick start available here https://github.com/wildfly/quickstart/tree/11.x/hibernate5

    Try the hibernate5 quick start, it should work.

    Have a look at the pom.xml, it contains

    <!-- Import the JPA API, we use provided scope as the API is included in WildFly -->
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.1-api</artifactId>
            <scope>provided</scope>
        </dependency>
    
        <!-- Bean Validation Implementation -->
        <!-- Provides portable constraints such as @Email -->
        <!-- Hibernate Validator is shipped in WildFly -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    
        <!--Import dependencies to hibernate packages(eg. hibernate-core)
            depending on features you want to use like Hibernate Session used in the
            quickstart -->
        <!--please note that scope is provided as these jars are shipped
            with as7 -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <scope>provided</scope>
        </dependency>
    

    Include that and it will work. I had to undeploy my app and restart wildfly.

    If you need to use another Hibernate version than the one provided in Wildfly, follow the official procedure to update the Hibernate version in Wildly, section Replacing the current Hibernate 5.x jars with a newer version.

    0 讨论(0)
  • 2020-11-29 05:02

    I am working with Eclipse Neon.3 (4.6.3) and Wildfly 10.1.0.

    What worked for me, was to restore an older standalone.xml file from the <wildfly>\standalone\configuration\standalone_xml_history directory. I shut down the server and then replaced the current configuration file with an older backup.

    I have no idea what changed in the configuration (I did not alter it manually), but it seems like the error message can be caused by changes in standalone.xml as well.

    Maybe this information is helpful, in case none of the other solutions works for you.

    0 讨论(0)
  • 2020-11-29 05:02

    I had the same problem. I followed this instruction and it worked. http://blog.triona.de/development/java/org-dom4j-documentfactory-classcastexception-on-hudson.html

    According to this post https://issues.jboss.org/browse/WFLY-5549 we need to create a file named boss-deployment-structure.xml with the content

    <?xml version="1.0" encoding="UTF-8"?>
    <jboss-deployment-structure>
        <deployment>
            <dependencies>
                <module name="org.dom4j"/>
            </dependencies>
        </deployment>
    </jboss-deployment-structure>
    

    Then place it into ../wildfly/modules/system/layers/base/org/jboss/as/product/wildfly-full/dir/META-INF

    I hope this would help.

    0 讨论(0)
  • 2020-11-29 05:06

    The other suggestions here either did not work for me or did not apply to my project. I found a possible solution in this blog. Basically it says to add Dependencies: org.dom4j export to {your war}/META-INF/MANIFEST.MF. I'm running Wildfly 10 and doing so in both my ear and ejb project seems to have worked.

    0 讨论(0)
  • 2020-11-29 05:08

    add dependency dom4j to pom with scope provided

    <dependency>
       <groupId>dom4j</groupId>
       <artifactId>dom4j</artifactId>
       <version>1.6.1</version>
       <scope>provided</scope>
    </dependency>
    
    0 讨论(0)
  • 2020-11-29 05:09

    In my case helped remove files from /data and /tmp

    0 讨论(0)
提交回复
热议问题