title: Hibernate, JPA, No Persistence provider for EntityManager named
body: <p>I'm working on a Swing application with JPA and Hibernate. But every time I try to call following code to get <code>EntityManager</code></p>
  
  <pre><code>try {
      Class.forName("org.postgresql.Driver");
  } catch (ClassNotFoundException e) {
      e.printStackTrace();
  }
  EntityManagerFactory emf = Persistence.createEntityManagerFactory("abcd");
  EntityManager em = emf.createEntityManager();
  </code></pre>
  
  <p>I get following exceptions:</p>
  
  <pre><code>Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named abcd: Provider named org.hibernate.jpa.HibernatePersistenceProvider threw unexpected exception at create EntityManagerFactory: 
  javax.persistence.PersistenceException
  javax.persistence.PersistenceException: Unable to build entity manager factory
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
  </code></pre>
  
  <p>Path to <code>persistence.xml</code> is <code>my.jar/meta-inf/persistence.xml</code></p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
               version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"&gt;
      &lt;persistence-unit name="abcd" transaction-type="RESOURCE_LOCAL"&gt;
          &lt;provider&gt;org.hibernate.jpa.HibernatePersistenceProvider&lt;/provider&gt;
          &lt;properties&gt;
              &lt;property name="hibernate.connection.url" value="xxx"/&gt;
              &lt;property name="hibernate.connection.password" value="xxx"/&gt;
              &lt;property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/&gt;
              &lt;property name="hibernate.connection.user" value="xxx"/&gt;
              &lt;property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/&gt;
          &lt;/properties&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>Dependencies:</p>
  
  <p>All dependencies except junit are in a classpath </p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
          &lt;artifactId&gt;junit&lt;/artifactId&gt;
          &lt;version&gt;4.8&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.persistence&lt;/groupId&gt;
          &lt;artifactId&gt;persistence-api&lt;/artifactId&gt;
          &lt;version&gt;1.0.2&lt;/version&gt;
          &lt;scope&gt;compile&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
          &lt;version&gt;4.3.10.Final&lt;/version&gt;
          &lt;scope&gt;compile&lt;/scope&gt;
      &lt;/dependency&gt;
  </code></pre>