title: javax.persistence.PersistenceException: No Persistence provider for EntityManager named
body: <p>I'm trying to set up a simple jpa 2.0 project by following the information provided by my teacher's documentation . I've been on this for hours now, but no matter what I do I always get this exception when I try to create a EntityManagerFactory:
  I've found quite a few similar questions regarding this exception, but no solutions that I am able to get to work. What am I doing wrong here?</p>
  
  <p>I created this project from Eclipse (no command prompt)</p>
  
  <pre><code>Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named course
      at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:56)
      at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)
      at message.SaveMessage.main(SaveMessage.java:8)
  </code></pre>
  
  <p><strong>directory structure</strong></p>
  
  <p><img src="https://i.stack.imgur.com/jjRCR.png" alt="enter image description here"></p>
  
  <p>my <strong>persistence.xml</strong></p>
  
  <pre><code>&lt;persistence xmlns="http://java.sun.com/xml/ns/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"&gt;
      &lt;persistence-unit name="course" transaction-type="RESOURCE_LOCAL"&gt;
  
          &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
  
  
          &lt;properties&gt;
              &lt;property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" /&gt;
              &lt;property name="hibernate.hbm2ddl.auto" value="update" /&gt;
  
              &lt;property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" /&gt;
              &lt;property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/StudentDB" /&gt;
              &lt;property name="javax.persistence.jdbc.user" value="root" /&gt;
              &lt;property name="javax.persistence.jdbc.password" value="pasapas2005" /&gt;
          &lt;/properties&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>My class </p>
  
  <pre><code>package message;
  
  import java.io.Serializable;
  
  import javax.persistence.*;
  
  @Entity
  public class Message implements Serializable {
  
      private long id;
      private String text;
  
      public Message() {
  
      }
  
      public Message(long id, String text) {
          this.setId(id);
          this.setText(text);
  
      }
  
      @Id
      public long getId() {
          return id;
      }
  
      public void setId(long id) {
          this.id = id;
      }
  
      public String getText() {
          return text;
      }
  
      public void setText(String text) {
          this.text = text;
      }
  
  }
  </code></pre>
  
  <p>My my tester (main) class</p>
  
  <pre><code>package message;
  
  import javax.persistence.*;
  
  public class SaveMessage {
  
      public static void main(String[] args) {
          EntityManagerFactory emf = Persistence.createEntityManagerFactory("course");
          EntityManager em = emf.createEntityManager();
          EntityTransaction tx = em.getTransaction();
          tx.begin();
  
          Message message = new Message(1, "Hello world");
          em.persist(message);
          tx.commit();
          em.close();
          System.out.println("message saved");
  
      }
  
  }
  </code></pre>