Monday, 1 May 2017

org/dom4j/DocumentException: Hibernate Error: Initial SessionFactory creation failed java.lang.NoClassDefFoundError:org/dom4j/DocumentException


Hibernate Error: Initial SessionFactory creation failed

java.lang.NoClassDefFoundError:org/dom4j/DocumentException


The below exception is very common and caused by missing the dependency library – dom4j.


Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException
       at com.hibernate.utils.HibernateUtil.getSessionFactory(HibernateUtil.java:15)
       at com.hibernate.application.RunApplication.main(RunApplication.java:16)
Caused by: java.lang.ClassNotFoundException: org.dom4j.DocumentException
       at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
       at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
       ... 2 more

Solution:

Download the dom4j  and the library jar file to the eclipse class path as shown below:


You can download the library here – 

Or

Add the dependency in Maven’s pom.xml
<dependency>
      <groupId>dom4j</groupId>
      <artifactId>dom4j</artifactId>
      <version>1.6.1</version>

</dependency>

You may also like to read the below posts:




No comments:

Post a Comment