If you miss the Hibernate commons annotations library hibernate-commons-annotations-4.0.4.Final.jar, then you would get java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/MetadataProvider exception.
<dependency> <groupId>hibernate-commons-annotations</groupId> <artifactId>hibernate-commons-annotations</artifactId> <version>4.0.4.GA</version> </dependency> <repositories> <repository> <id>JBoss repository</id> <url>http://repository.jboss.com/maven2/</url> </repository> </repositories>
Exception Trace
Exception in thread "main" java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/MetadataProvider at javabeat.net.hibernate.HibernateUtil.main(HibernateUtil.java:12) Caused by: java.lang.ClassNotFoundException: org.hibernate.annotations.common.reflection.MetadataProvider at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source)