Home >Java >javaTutorial >JPA: Why 'No Persistence Provider' Error When Creating EntityManagerFactory?
JPA: "No Persistence provider for EntityManager named"
When attempting to create an EntityManagerFactory using Persistence.createEntityManagerFactory("agisdb"), an error occurred stating "No Persistence provider for EntityManager named agisdb." Despite having a persistence.xml file with the correct name in the META-INF directory, the issue persists.
Solution
The underlying problem is the absence of the necessary JAR file in the application's classpath. To resolve this:
For development environments like Eclipse:
For command-line applications:
After ensuring the necessary JAR file is present in the classpath, the application should be able to successfully create an EntityManagerFactory without encountering the "No Persistence provider" error.
The above is the detailed content of JPA: Why 'No Persistence Provider' Error When Creating EntityManagerFactory?. For more information, please follow other related articles on the PHP Chinese website!