Caused by: java.lang.ClassNotFoundException: org.dom4j.io.STAXEventReader

后端 未结 5 1846
别跟我提以往
别跟我提以往 2020-12-11 12:59

I am developing a web service application but sessionFactory bean is not creating because of below error. I can\'t see duplicate or conflict version of dom4j jar. I tried va

相关标签:
5条回答
  • 2020-12-11 13:28

    I used Ivy dependency manager and in my case I remove dom4j from core dependency and again add the last version 1.6.1 and that worked for me.

    <dependency org="org.hibernate" name="hibernate-core" rev="5.2.8.Final">
        <exclude  org="dom4j"/>
    </dependency>
    
    <dependency org="dom4j" name="dom4j" rev="1.6.1"/>
    
    0 讨论(0)
  • 2020-12-11 13:36

    You won't need to apply exclusions. Simply fix this by deleting your local repository and then re download libraries by doing the Alt+F5 + force update.

    Doing this solved the issue for me.

    0 讨论(0)
  • 2020-12-11 13:41

    In my case with the same problem I solve it setting this versions in pom.xml:

    • Spring version 4.3.7.RELEASE
    • Hibernate version 4.1.9.Final

    I did't use <exclusions> at all and I added dom4j with version 1.4.

    <dependency>
        <groupId>dom4j</groupId>
        <artifactId>dom4j</artifactId>
        <version>1.4</version>
    </dependency> 
    
    0 讨论(0)
  • 2020-12-11 13:46

    In my scenario, same stacktrace, I followed the answers without success. The solution was to remove dom4j from .m2/repository because apparently the jar was corrupt, and after downloaded again the problem was fixed.

    0 讨论(0)
  • 2020-12-11 13:48

    Thanks to Hohenheim to point out the version issue.

    Hibernate core 5.1.0.Final include dom4j-1.6.1 jar which throws this error. To fix this, need to exclude dom4j-1.6.1 from hibernate-core and include dom4j-1.6 in your pom.

    I am not able find the exact reason why this is happening.

    This is how I excluded dom4j from pom in hibernate dependency.

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>5.1.0.Final</version>
        <exclusions>
            <exclusion>
                <artifactId>jta</artifactId>
                <groupId>javax.transaction</groupId>
            </exclusion>
            <!-- Exclude SLF4j to avoid version conflicts (we have 1.6.6, this drags 
                    in 1.6.1) -->
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>
            <!-- Exclude dom4j to avoid version conflicts (we have 1.6, this drags 
                    in 1.6.1) -->
            <exclusion>
                <groupId>dom4j</groupId>
                <artifactId>dom4j</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    
    0 讨论(0)
提交回复
热议问题