2

I got a sample project, copied from somewhere else, when I am trying to run it in netbeans I am getting some error/exceptions in tomcat's console window.

java.lang.ClassNotFoundException: javax.persistence.Entity
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
    at org.springframework.core.type.classreading.RecursiveAnnotationAttributesVisitor.visitEnd(AnnotationAttributesReadingVisitor.java:167)
    at org.springframework.asm.ClassReader.a(Unknown Source)
    at org.springframework.asm.ClassReader.accept(Unknown Source)
    at org.springframework.asm.ClassReader.accept(Unknown Source)

javax.persistence is already added to my project. I even removed and re-added in netbeans but still same error. This error is when running the web applictation not when compiling. enter image description here

6
  • 1
    You need to add the Persistence Jar Files to your BuildPath. Commented Oct 17, 2012 at 11:02
  • Which version of tomcat you are using ? Commented Oct 17, 2012 at 11:02
  • You are missing some jars regarding JPA Commented Oct 17, 2012 at 11:02
  • Ok, added some info on how to download the jar files. You need to create a directory called lib in your project set up, add the jars there, then include them in your build path . For this right click on project -> goto java build path -> add jars . Commented Oct 17, 2012 at 11:07
  • Are you getting tomcat 7 welcome page , when you start the server in your localhost:8080 or whatever your port no is set at ? Commented Oct 17, 2012 at 11:12

2 Answers 2

1

You need to add following Jar Files to your Build Path: -

  • javax.persistence_2.0.3.v201010191057.jar
  • org.eclipse.persistence.jpa_2.3.0.v20110604-r9504.jar
  • org.eclipse.persistence.jpa.equinox_2.3.1.v20111018-r10243.jar
  • org.eclipse.persistence.antlr_2.3.0.v20110604-r9504.jar
  • org.eclipse.persistence.asm_2.3.0.v20110604-r9504.jar

Preferably adding the first one will work, as javax.persistence.Entity is found in that Jar only. But you may also need to add the later ones, for working with JPA

Google them with the name of JPA Jars. You will get them.

Sign up to request clarification or add additional context in comments.

10 Comments

how to add a jar file to build path?
@coure2011 You need to create a lib folder under your Project directory, and add all the Jar files in that folder.
Only doing that will not help, he needs to import the jars in his build path from lib dir
@TheDarkKnight Yeah that's what the links I gave tells. I gave to him so that he can understand it better..
|
0

The javax.persistence.Entity is a class inside the Java EE SDK library “javaee.jar“, you are missing this jar file in your project classpath.

refer this http://www.mkyong.com/hibernate/java-lang-classnotfoundexception-javax-persistence-entity/

1 Comment

I don't think this is the right solution for Tomcat. You only need the JPA-API JAR file ... not all of the J2EE APIs. (You already have a lot of the J2EE APIs and implementation classes in Tomcat.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.