title: Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named TEST
body: <p>I work on a project in JPA, I connected it with a MySQL database that contains tables already filled using the GlassFish server, I created a test class to test to display a column of a table With a SELECT query but I still have a persistence provider problem even though I have configured my persistence.xml file</p>
  
  <p>Entity :</p>
  
  <pre><code>package org.planetjpa;
  import java.io.Serializable;
  import java.util.Date;
  import javax.persistence.*;
  
  @Entity
  @Table(name="films", schema = "database")
  public class Films implements Serializable {
  
       @Id@Column(name="id")
       private int id_film;
      @Column(name="titre")
      private String nom_film;
      @Column(name="realisateur")
      private String realisateur;
      @Column(name="date")
      private Date date_film;
      @Column(name="cadre")
      private String cadre;
      @Column(name="lieu")
      private String lieu_film;
      @Column(name="arrondissement")
      private int arrondissement;
      @Column(name="adresse")
      private String adresse;
      @Column(name="cinema")
      @SequenceGenerator(name = "id_Sequence_cinema", sequenceName = "ID_SEQ_CINEMA")
      private String cinema;
      @Column(name="prix")
      private double prix;
      @Column(name="nb_personne")
      private int nb_places;
      private static final long serialVersionUID = 1L;
  
  public Films() {
      super();
  }
  
  
  public int getId_film() {
      return id_film;
  }
  
  public void setId_film(int id_film) {
      this.id_film = id_film;
  }
  
  public String getNom_film() {
      return nom_film;
  }
  
  public void setNom_film(String nom_film) {
      this.nom_film = nom_film;
  }
  
  public String getRealisateur() {
      return realisateur;
  }
  
  public void setRealisateur(String realisateur) {
      this.realisateur = realisateur;
  }
  
  public Date getDate_film() {
      return date_film;
  }
  
  public void setDate_film(Date date_film) {
      this.date_film = date_film;
  }
  
  public String getCadre() {
      return cadre;
  }
  
  public void setCadre(String cadre) {
      this.cadre = cadre;
  }
  
  public String getLieu_film() {
      return lieu_film;
  }
  
  public void setLieu_film(String lieu_film) {
      this.lieu_film = lieu_film;
  }
  
  public int getArrondissement() {
      return arrondissement;
  }
  
  public void setArrondissement(int arrondissement) {
      this.arrondissement = arrondissement;
  }
  
  public String getAdresse() {
      return adresse;
  }
  
  public void setAdresse(String adresse) {
      this.adresse = adresse;
  }
  
  public String getCinema() {
      return cinema;
  }
  
  public void setCinema(String cinema) {
      this.cinema = cinema;
  }
  
  public double getPrix() {
      return prix;
  }
  
  public void setPrix(double prix) {
      this.prix = prix;
  }
  
  public int getNb_places() {
      return nb_places;
  }
  
  public void setNb_places(int nb_places) {
      this.nb_places = nb_places;
  }
  
  public static long getSerialversionuid() {
      return serialVersionUID;
  }
  }
  </code></pre>
  
  <p>Main :</p>
  
  <pre><code>package org.test;
  
  import javax.persistence.EntityManager;
  import javax.persistence.EntityManagerFactory;
  import javax.persistence.EntityTransaction;
  import javax.persistence.*;
  
  import org.planetjpa.Films;
  
  import java.util.List;
  
  public class Test {
          public static void main(String[] args) {
  
  Films book = new Films();
  
  // Obtains an entity manager and a transaction
  EntityManagerFactory emf = Persistence.createEntityManagerFactory("TEST");
  EntityManager em = emf.createEntityManager();
  EntityTransaction tx = em.getTransaction();
  
  
  // Persists the book to the database
  tx.begin();
  em.persist(book);
  tx.commit();
  
  
  TypedQuery&lt;Films&gt; tq =em.createQuery("Select b from Films b",Films.class);
  List&lt;Films&gt; lb = tq.getResultList();
  for (Films b:lb) System.out.println("######### " + b.getCinema());
  
  //Closes the entity manager and the factory
  //em.close();
  emf.close();
  
  }
  } 
  </code></pre>
  
  <p>persistence.xml :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"&gt;
  &lt;persistence-unit name="TEST" transaction-type="RESOURCE_LOCAL"&gt;
  
      &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
  
  
      &lt;class&gt;org.planetjpa.Films&lt;/class&gt;
      &lt;class&gt;org.planetjpa.Lieux&lt;/class&gt;
      &lt;class&gt;org.planetjpa.Scences&lt;/class&gt;
  
  
  
      &lt;properties&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/database/projetjsf"/&gt;
          &lt;property name="javax.persistence.jdbc.username" value="root"/&gt;
          &lt;property name="javax.persistence.jdbc.password" value="amine1993"/&gt;
  
  
          &lt;property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" /&gt;
          &lt;property name="hibernate.show_sql" value="true" /&gt;
          &lt;property name="hibernate.hbm2ddl.auto" value="create" /&gt;
      &lt;/properties&gt;
  
  &lt;/persistence-unit&gt;
  </code></pre>
  
  <p></p>
  
  <p>I tried to put the Main and the Entity in the same package but i still have the same problem.</p>
  
  <p>Result :</p>
  
  <p><img src="https://i.stack.imgur.com/ShYJN.jpg" alt="PersistenceException"></p>