I have problem with creating executable jar file. I creating the jar file by Intellij idea X artifacts. But when I try to execute this jar, it gave me an error:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/persistence/EntityNotFoundException
Caused by: java.lang.ClassNotFoundException: javax.persistence.EntityNotFoundException
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
I check which package contains this class and I found it in this maven dependency:
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
</dependency>
I check if the Intellij add this jar to my executable jar and I found it there. So have someone any Idea where the problem is?
尝试将javaee-api-5.0-2.jar添加到您的项目中。
Indeed, hibernate-jpa-2.0-api
contains this class.
It might be a classpath issue. Are you including required jar libraries in your jar? Can your app access other application provided jars at runtime? You may find the answers to this question useful: Classpath including JAR within a JAR
The JPA libs are a separate external download from Oracle. You may need to download them separately and install them into your local Maven repo.
You should also be specifying a version in your dependency XML.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.