javax.persistence.PersistenceException: No Persistence provider for EntityManager named employeeEntityManager
Exception:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named employeeEntityManager
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
at EmployeeDaoImpl.create(EmployeeDaoImpl.java:21)
at EmployeeDaoImpl.main(EmployeeDaoImpl.java:25)
The PersistenceException hierarchy is :
· java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
javax.persistence.PersistenceException
Solutions:
Below are would be help to resolve the above exception:
1. Extract war/ear file and check the META-INF folder contains the persistence.xml, if miss this file we have to add either manually or using the build tools like MAVEN or ANT put into specified location.
2. After placed the persistence.xml in META-INF folder, still getting the same exception kindly check the all entities are defined under <entities> tag. If not add those entities in persistence.xml under META-INF folder.
3. Check the dependency jars and add JPA API related jars too in classpath of the project.
4. To define the persistence.xml if using the absolute path double check once is it correct or not.
5. The folder path would be like src/main/resource/META-INF/persistence.xml
---
---
(please be revisit for more solutions for the exception)
Comments
Post a Comment