No Persistence provider for EntityManager

No Persistence provider for EntityManager” error message seemingly comes from nowhere.

While working with JPA and using Hibernate ORM as a persistence provider, one can get into a situation when the code suddenly stops working. The application cannot even start, and the log captures the message “No Persistence provider for EntityManager xyz” where “zyz” is the name of the persistence unit in the persistence.xml

Internet search shows that many if such situations are caused by some typo in persistence.xml

But if the persistence.xml file was not changed or you check and cannot see any problem in it, think about the changes to the code you have done just before the application stopped working. If the entity class was changed or a new entity class was added, there is a good chance that the error is related to that change.

Try to roll back the change and see if the error goes away. If yes, then introduce the change in small steps and see which one breaks the system.

If suddenly the message “No Persistence provider for EntityManager xyz appears again and there is no better indicator of the root cause, try to downgrade the hibernate-core library version in pom.xml. In my experience, it leads sometimes to a more specific error message and reveals that the root cause has nothing to do with the persistence.xml

, ,

Send your comments using the link Contact or in response to my newsletter.
If you do not receive the newsletter, subscribe via link Subscribe under Contact.

Powered by WordPress. Designed by Woo Themes