Published on Sep 24 2014 in Java

One of possible causes for java.lang.NoClassDefFoundError: javax/persistence/EntityListeners

java.lang.NoClassDefFoundError: javax/persistence/EntityListeners

It is usually caused by missing hibernate-jpa jars. These may be included in your development environment but mising in the generated WAR. You need to ensure the JPA jar is included in your WAR's WEB-INF/lib or your application server's global lib directory or somewhere else in the classpath.

For example for Hibernate 4.2.6 it can be found in hibernate-release-4.2.6.Final.tgz (hibernate-release-4.2.6.Final/lib/required/hibernate-jpa-2.0-api-1.0.1.Final.jar). For other versions it can be in an other file or location as hibernate parts were moved recently between jars. For example keeps it in hibernate-distribution-3.6.0.Final/lib/hibernate-jpa-2.0-api-1.0.0.Final.jar.

Hibernate versions earlier than 3.6 were using modules for annotations, entitymanager and core. Core (distributed as hibernate3.jar) had no JPA dependency.