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
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"/>
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.
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>
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.
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>