Saturday, June 1, 2013

What will happen when JPA jar is missing in the classpath?

JPA jar is needed when using Hibernate version 3.6.0. Missing JPA jar in the classpath will have following error. No worry, the JPA jar is bundle together with the same distribution as the Hibernate package, include it into your classpath now!!
Exception in thread "main" java.lang.NoClassDefFoundError: javax/persistence/EntityListeners
 at org.hibernate.cfg.annotations.reflection.JPAMetadataProvider.getDefaults(JPAMetadataProvider.java:96)
 at org.hibernate.annotations.common.reflection.java.JavaReflectionManager.getDefaults(JavaReflectionManager.java:226)
 at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1385)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1856)
 at org.huahsin.MainApp.main(MainApp.java:12)
Caused by: java.lang.ClassNotFoundException: javax.persistence.EntityListeners
 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:306)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
 ... 5 more

No comments: