Wednesday, August 25, 2010

Exception in thread "main" java.lang.NoClassDefFoundError: javax.persistence.Cacheable

When you are working with Hibernate using the Annotations, you will get the following exceptions
Exception in thread "main" java.lang.NoClassDefFoundError:javax.persistence.Cacheable 
even though you have added the required libraries that comes with the Hibernate distribution final 3.5 as well as ejb3-persistence.jar.
The reason for this javax.persistence.Cacheable is part of JPA 2.0 specification. To overcome this issue, you need to add the following JAR file hibernate-jpa-2.0-api-1.0.0.Final.jar, which will be available under /lib/jpa directory in Hibernate distribution.

Happy programming

5 comments:

  1. Thank you! You just saved me so much time!

    ReplyDelete
  2. Thanks Ramanujam. You saved my hours of work because I was trying with several version of *.jar files in my Eclipse IDE.

    Good work !

    ReplyDelete