title: EclipseLink JPA error: "javax.persistence.PersistenceException: No Persistence provider for EntityManager named (...)"
body: <p>I'm using Struts 2 2.5.20 with EclipseLink JPA 2.7.4 in a Eclipse Java EE project. I believe there is some kind of problem with my <code>persistence.xml</code> file, since when I try to create a new <code>EntityManagerFactory</code> I get this error:</p>
  
  <blockquote>
    <p>WARNING: javax.persistence.spi::No valid providers found.
    Exception in thread "main" javax.persistence.PersistenceException: No > Persistence provider for EntityManager named c_manager
      at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:86)
      at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
      at contactManager.main.JPAImpl.main(JPAImpl.java:26)</p>
  </blockquote>
  
  <p>Although I've found dozens of questions here in SO with this particular error, none of the solutions provided worked for me.</p>
  
  <p><strong>JPAImpl.java</strong></p>
  
  <pre><code>public class JPAImpl
  {
  
      public static void main(String[] args)
      {
          EntityManagerFactory factory = Persistence.createEntityManagerFactory("c_manager");
          EntityManager em = factory.createEntityManager(); //line 26
  (...)
  </code></pre>
  
  <p><strong>Persistence.xml</strong></p>
  
  <pre class="lang-xml prettyprint-override"><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 persistence_1_0.xsd" version="1.0"&gt;
      &lt;persistence-unit name="c_manager" transaction-type="RESOURCE_LOCAL"&gt;
  
  &lt;provider&gt;org.eclipse.persistence.jpa.PersistenceProvider&lt;/provider&gt;
          &lt;class&gt;contactManager.model.jpa.entity.Contact&lt;/class&gt;
          &lt;exclude-unlisted-classes&gt;false&lt;/exclude-unlisted-classes&gt;
          &lt;properties&gt;
              &lt;property name="javax.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver"/&gt;
              &lt;property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/contact_manager?serverTimezone=UTC"/&gt;
              &lt;property name="javax.persistence.jdbc.user" value="root"/&gt;
              &lt;property name="javax.persistence.jdbc.password" value="root"/&gt;
          &lt;/properties&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p><strong>Project structure</strong></p>
  
  <p><a href="https://i.stack.imgur.com/EFsDf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EFsDf.png" alt="enter image description here"></a></p>
  
  <p><strong>Classpath</strong></p>
  
  <p><a href="https://i.stack.imgur.com/Zt0Ye.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Zt0Ye.png" alt="enter image description here"></a></p>