Thursday, March 15, 2012

No Persistence provider for EntityManager named testuser


Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named testuser
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:69)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
at main.TestUser.main(TestUser.java:19)

Reason:

persistence.xml is not in the META-INF folder.

Solution:

When using Java Persistence API outside the container the persistence.xml must be in folder src\META-INF. Add src to the classpatch not META-INF.

1 comment:

  1. Hi, my persistence.xml it's in the src/META-INF but the error remains... Sorry by the english, i'm brazilian

    ReplyDelete