My Quotes


When U were born , you cried and the world rejoiced
Live U'r life in such a way that when you go
THE WORLD SHOULD CRY






Saturday, January 26, 2013

Persistence Unit not found - JPA- RESOLVED

Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named

This is so annoying

I had been looking for solutions for the same. Here are the pointers for the same

Hope this helps someone.

  1. My project structure is as follows . I am using JPA2.0
  2. .
    ├── pom.xml
    └── src
        ├── main
           ├── java
              └── se
                  └── mycomp
                      ├── UserTest.java
                      └── domain
                          └── User.java
           └── resources
               ├── META-INF
                  └── persistence.xml
               └── log4j.properties
        └── test
            └── java
  3. Compare the case sensitiveness for the Persistence Unit Name.
  4. If you have JPA2.0 as a dependency, you can go ahead and remove the same
  5. Check if your provider is 
  6. <persistence-unit name="manager1" transaction-type="RESOURCE_LOCAL">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
    Check your pom.xml if you have hibernate entity manager as a dependency.
    If needed add the hibernate annotations too . No HARM
       <dependency>
          <groupId>org.hibernate</groupId>
          <artifactId>hibernate-entitymanager</artifactId>
          <version>${hibernate-core-version}</version>
        </dependency>
    
    
    Thats it, the errors are gone.

No comments :