Saturday 29 April 2017

Hibernate Error: Exception in thread "main" java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/MetadataProvider


Exception in thread "main" java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/MetadataProvider:






Exception Details:


Exception in thread "main" java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/MetadataProvider
       at com.hibernate.utils.HibernateUtil.getSessionFactory(HibernateUtil.java:15)
       at com.hibernate.application.RunApplication.main(RunApplication.java:16)
Caused by: java.lang.ClassNotFoundException: org.hibernate.annotations.common.reflection.MetadataProvider
       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

This is caused by missing of the Hibernate commons annotations library.

Library: hibernate-commons-annotations-3.2.0.Final.jar

Download the above library from the hibernate official website, and add it to the build path as shown below:


Or
Add the dependency in Maven’s pom.xml.

<dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-commons-annotations</artifactId>
        <version>3.2.0.Final</version>

    </dependency>



You may like to read the below posts:

Association, Aggregation, Composition
Creating SOAP Web Services using JAX-WS
Difference between SOAP and REST web services
Testing the SOAP web services using SOAP UI
Equals and Hashcode() Interview questions
What will happen if equals and hashcode not overridden



Read More »