If you are setting up the first hibernate application, there is chance that you would get the following exception if the required dependency is missed. The reason is you have not included the dom4j-1.6.1.jar file which is used internally by the hibernate core for parsing the XML documents. The result will be the following exception. Either you can download the file from their dom4j project or add the following maven dependency in your project’s POM.xml to resolve the following exception.
<dependency> <groupId>dom4j</groupId> <artifactId>dom4j</artifactId> <version>1.6.1</version> </dependency>
Exception Trace
Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException at javabeat.net.hibernate.HibernateUtil.main(HibernateUtil.java:10) Caused by: java.lang.ClassNotFoundException: org.dom4j.DocumentException at java.net.URLClassLoader$1.run(URLClassLoader.java:217) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:266)