Just for completeness. There is another situation causing this error:
missing META-INF/services/javax.persistence.spi.PersistenceProvider file.
For Hibernate, it's located in hibernate-entitymanager-XXX.jar
, so, if hibernate-entitymanager-XXX.jar
is not in your classpath, you will got this error too.
This error message is so misleading, and it costs me hours to get it correct.
See JPA 2.0 using Hibernate as provider - Exception: No Persistence provider for EntityManager.