I get the following exception
ClassNotFoundException: jakarta.persistence.Persistencee
This error happens in my standalone Java web-app I am trying to use JPA with it. I have normally used JPA in a container and have done for years. You can view a very simple app here: (https://github.com/pramodShehan5/jpa-example ) that displays the same behavior.
File pom.xml
contains the following dependencies
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core-jakarta</artifactId>
<version>5.6.14.Final</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.6.0</version>
</dependency>
</dependencies>
When this sample app is compiled with mvn compile
all is fine.
cd target/classes
java org.example.Main
Error
Exception in thread "main" java.lang.NoClassDefFoundError: jakarta/persistence/Persistence
at org.example.Main.main(Main.java:21)
Caused by: java.lang.ClassNotFoundException: jakarta.persistence.Persistence
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
So the problem as I see it is I need a provider added into my jar and this is where I need help. Can anyone point out what I need to add to my pom file to give me a provider (assuming that is really what I am missing) or do I just need to get one of the GlassFish JARs on the classpath to do this for me?