Hibernate Error - java.lang.NoClassDefFoundError: org/dom4j/DocumentException



This is a common problem in Hibernate application
Initial SessionFactory Creation Failed.Java.Lang.NoClassDefFoundError: Org/Dom4j/DocumentException.

Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException
 at com.sample.hibernate.dao.PersonsDAO.getSession(PersonsDAO.java:28)
 at com.sample.hibernate.dao.PersonsDAO.<init>(PersonsDAO.java:23)
 at com.sample.hibernate.driver.HibernateRunner.main(HibernateRunner.java:15)
Caused by: java.lang.ClassNotFoundException: org.dom4j.DocumentException
 at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
 ... 3 more




Problem:
Your application class path do not have dom4j library.

dom4j:
dom4j is an easy to use library for working with XML, XPath and XSLT on the Java platform using the Java Collections Framework and with full support for DOM, SAX and JAXP.

Why dom4j in hibernate application:
Hibernate usesdom4j as API for manipulating XML trees.

Resolution:
Download and add dom4j library to the build path of your application.

dom4j official website: http://dom4j.sourceforge.net/






Reactions:

0 comments :

Post a Comment