While working with hibernate this error can be faced. This is because absence of ‘hibernate-jpa-2.0-api-x.x.x.Final.jar’ in your classpath.
- Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: javax/persistence/EntityListeners
- Exception in thread "main" java.lang.ExceptionInInitializerError
- at hibernate.HibernateUtil.buildSessionFactory(HibernateUtil.java:18)
- at hibernate.HibernateUtil.<clinit>(HibernateUtil.java:8)
- at driver.Driver.main(Driver.java:14)
- Caused by: 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 hibernate.HibernateUtil.buildSessionFactory(HibernateUtil.java:15)
- ... 2 more
- 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:307)
- at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
- at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
- ... 7 more
What is Hibernate JPA?
The JPA 2.0 compatible Hibernate EntityManager is built on top of the core of Hibernate and Hibernate Annotations.This is the JAR containing the JPA 2.0 API, it provides all the interfaces and concrete classes that the specification defines as public API.
Click here to download and read more about hibernate JPA.
Your Suggestion Are Always Welcomed.