title: Can't find persistence.xml
body: <p>I try to use jpa with spring-orm and hibernate.</p>
  
  <p>I have mysql db with TRADES table. I try to work with this table using jpa.
  I try to test EntityManager creation using persistence.xml but I get an exception that "No Persistence provider for EntityManager named [persistence-unit-name from persistence.xml]"
  As I watched in another such questions, it's mean for my situation that persistence.xml file is not found.</p>
  
  <p>When I try to test this configuration I get an exception that persistence.xml wasn't find, as I think.</p>
  
  <pre><code>SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
  SLF4J: Defaulting to no-operation (NOP) logger implementation
  SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
  Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named trade-mysql-pu
      at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
      at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
      at com.madhusudhan.jsd.jpa.EntityManagerTest.init(EntityManagerTest.java:16)
      at com.madhusudhan.jsd.jpa.EntityManagerTest.main(EntityManagerTest.java:29)
  </code></pre>
  
  <p>I can't figure out why this is happening. Could you help me?
  Thanks.</p>
  
  <p>Table:</p>
  
  <pre><code>create table TRADES (ID int NOT NULL, 
      ACCOUNT VARCHAR(20) NOT NULL, 
      SECURITY VARCHAR(10) NOT NULL, 
      QUANTITY INT NOT NULL, 
      STATUS VARCHAR(10), 
      DIRECTION VARCHAR(10)
  );
  </code></pre>
  
  <p>entity class for this table:</p>
  
  <pre><code>package com.madhusudhan.jsd.domain.jpa;
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.Table;
  
  @Entity
  @Table(name="trades")
  public class Trade {
  
      private int id;
      private String direction;
      private String account;
      private String security;
      private String status;
      private int quantity;
  
      @Column(nullable=false)
      @Id
      @GeneratedValue(strategy=GenerationType.AUTO)
      public int getId() {
          return id;
      }
      public void setId(int id) {
          this.id = id;
      }
  
      @Column
      public String getDirection() {
          return direction;
      }
      public void setDirection(String direction) {
          this.direction = direction;
      }
  
      @Column
      public String getAccount() {
          return account;
      }
      public void setAccount(String account) {
          this.account = account;
      }
  
      @Column
      public String getSecurity() {
          return security;
      }
      public void setSecurity(String security) {
          this.security = security;
      }
  
      @Column
      public String getStatus() {
          return status;
      }
      public void setStatus(String status) {
          this.status = status;
      }
  
      @Column
      public int getQuantity() {
          return quantity;
      }
      public void setQuantity(int quantity) {
          this.quantity = quantity;
      }
  
      @Override
      public String toString() {
          return "Trade [id=" + id + ", direction=" + direction + ", account="
                  + account + ", security=" + security + ", status=" + status
                  + "]";
      }
  
  }
  </code></pre>
  
  <p>And persistence.xml in src/main/resources/META-INF</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="trade-mysql-pu" transaction-type="RESOURCE_LOCAL"&gt;
          &lt;provider&gt;org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter&lt;/provider&gt;
          &lt;class&gt;com.madhusudhan.jsd.domain.jpa.Trade&lt;/class&gt;
          &lt;properties&gt;
              &lt;property name="hibernate.hbm2ddl.auto" value="validate" /&gt;
              &lt;property name="show_sql" value="true" /&gt;
              &lt;property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/JSDATA"/&gt;
              &lt;property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/&gt;
              &lt;property name="hibernate.connection.username" value="prospring4"/&gt;
              &lt;property name="hibernate.connection.password" value="prospring4"/&gt;
              &lt;property name="hibernate.connection.pool_size" value="1"/&gt;
              &lt;property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/&gt;
          &lt;/properties&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>This is the test class:</p>
  
  <pre><code>package com.madhusudhan.jsd.jpa;
  
  import javax.persistence.EntityManager;
  import javax.persistence.EntityManagerFactory;
  import javax.persistence.Persistence;
  
  import com.madhusudhan.jsd.domain.jpa.Trade;
  
  public class EntityManagerTest {
  
      private EntityManagerFactory factory;
      private EntityManager entityManager;
  
      private void init() {
          factory = Persistence.createEntityManagerFactory("trade-mysql-pu");
          entityManager = factory.createEntityManager();
      }
  
      public void persistTrade(Trade t) {
          entityManager.persist(t);
      }
  
      public static void main(String[] args) {
          EntityManagerTest test = new EntityManagerTest();
          test.init();
      }
  }
  </code></pre>
  
  <p>dependencies from build.gradle:</p>
  
  <pre><code>dependencies {
      compile 'org.springframework:spring-context:4.1.6.RELEASE'
      compile 'org.springframework:spring-jdbc:4.1.6.RELEASE'
      compile 'org.springframework:spring-orm:4.1.6.RELEASE'
      compile 'commons-dbcp:commons-dbcp:1.4'
      compile 'mysql:mysql-connector-java:5.1.18'
      compile 'org.hibernate:hibernate-core:3.6.0.Final'
      compile 'org.hibernate:hibernate-entitymanager:3.6.0.Final'
      compile 'junit:junit:4.7'
      compile 'log4j:log4j:1.2.14'
  }
  </code></pre>