title: Hibernate JPA - Error: No Persistence provider for EntityManager
body: <p>I'm writing my first Hibernate JPA project. I have a very common issue (I found many articles about it) but no solution for me. </p>
  
  <p>When i run application I've got this error: </p>
  
  <pre><code>Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named JpaTest2
  at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:69)
  at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
  at net.andy.DatabaseAccess.testJpa(DatabaseAccess.java:55)
  at net.andy.Main.main(Main.java:11)
  </code></pre>
  
  <p>My persistence.xml is: </p>
  
  <pre><code>&lt;persistence-unit name="pu3" transaction-type="RESOURCE_LOCAL"&gt;
  &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
  &lt;class&gt;net.andy.Writer&lt;/class&gt;
    &lt;properties&gt;
       &lt;property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/&gt;
       &lt;!--  &lt;property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/&gt; --&gt;
       &lt;property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/&gt;
       &lt;property name="hibernate.connection.username" value="postgres"/&gt;
       &lt;property name="hibernate.connection.password" value="postgres"/&gt;
       &lt;property name="hibernate.connection.url" value="jdbc:postgresql://localhost:5432/testdb"/&gt;
       &lt;property name="hibernate.max_fetch_depth" value="3"/&gt;
    &lt;/properties&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p>And this is my class where I try to save something to db: </p>
  
  <pre><code>    public static void testJpa() {
  
      // Use persistence.xml configuration
  
      EntityManagerFactory emf = Persistence.createEntityManagerFactory("JpaTest2");
      EntityManager em = emf.createEntityManager();
  
      // Work with the EM
      Writer w = new Writer();
      //MapEntity map = new MapEntity();
      w.setId(5);
  
      EntityTransaction transaction = em.getTransaction();
      transaction.begin();
      em.persist(w);
      transaction.commit();
      em.close();
      emf.close(); 
  }
  </code></pre>
  
  <p>I have read many articles which describes this error. 
  So far I have: </p>
  
  <ol>
  <li>added  line in persistence.xml.  </li>
  <li>changed persistence.xml
  location (I've tried probably everyone location also meta-inf
  folder, myproject/src etc.) </li>
  <li>added libs hibernate-core,
  hibernate-entitymanager, hibernate-commons-annotations,
  ejb3-persistence, hibernate-jpa, jta, postgresqljdbc (and a few
  more).</li>
  </ol>
  
  <p>How to solve this? Almost code above is copied from tutorials, so I think there are some problems in libs or project structure, but can't find correct reason of this issue.</p>