Deployed war to tomcat can't throws java.lang.NoClassDefFoundError: javax/persistence/PersistenceException

强颜欢笑 提交于 2019-12-06 11:18:51

You seem to be missing the javax.persistence.PersistenceException class (part of the JPA spec).

The Java Persistence API JAR (containing the PersistenceException class) can be found here :

http://repo1.maven.org/maven2/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar

This JAR needs to be in your WEB-INF/lib folder.

Depending on how you've setup your Eclipse, it probably pushed these JARs to Tomcat automatically (by defining a library).

However, the fact that it tries to load the PersistenceException most likely means that another exception (the real exception) will occur once you solve this ClassNotFoundException.

If you are using Maven for managing project dependencies, then including the following in my pom.xml worked for me:

<!-- https://mvnrepository.com/artifact/javax.persistence/persistence-api -->
<dependency>
    <groupId>javax.persistence</groupId>
    <artifactId>persistence-api</artifactId>
    <version>1.0.2</version>
</dependency>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!