title: Using JPA2.1 on Weblogic12 with Hibernate 5: java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.jpa.HibernatePersistenceProvider
body: <p>I'm getting really frustrated with the simple task of trying to use a JPA 2.1 PersistenceManager with Hibernate 5.</p>
  
  <p>I package a simple web service built with the weblogic ant task jwsc (weblogic.wsee.tools.anttasks.JwscTask)
  but when deploying I get this <code>NoClassDefFoundError</code>:</p>
  
  <pre><code>[wldeploy] [BasicOperation.execute():472] : Initiating deploy operation for app, import2, on targets:
   [wldeploy] [BasicOperation.execute():474] :    myserver
   [wldeploy] Task 0 initiated: [Deployer:149026]deploy application import2 on myserver.
   [wldeploy] dumping Exception stack
   [wldeploy] Task 0 failed: [Deployer:149026]deploy application import2 on myserver.
   [wldeploy] Target state: deploy failed on Server myserver
   [wldeploy] java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.jpa.HibernatePersistenceProvider
   [wldeploy]     at java.lang.Class.forName0(Native Method)
   [wldeploy]     at java.lang.Class.forName(Class.java:348)
   [wldeploy]     at weblogic.persistence.BasePersistenceUnitInfo.getPersistenceProvider(BasePersistenceUnitInfo.java:441)
   [wldeploy]     at weblogic.persistence.BasePersistenceUnitInfo.initializeEntityManagerFactory(BasePersistenceUnitInfo.java:461)
   [wldeploy]     at weblogic.persistence.BasePersistenceUnitInfo.initializeEntityManagerFactory(BasePersistenceUnitInfo.java:454)
   [wldeploy]     at weblogic.persistence.BasePersistenceUnitInfo.init(BasePersistenceUnitInfo.java:141)
  </code></pre>
  
  <p>The class org.hibernate.jpa.HibernatePersistenceProvider is provided in hibernate-entitymanager-5.0.4.Final.jar.</p>
  
  <p>My import2.war DOES include this jar in 
  WEB-INF/lib along with other things:</p>
  
  <pre><code>hibernate-commons-annotations-5.0.0.Final.jar
  hibernate-core-5.0.4.Final.jar
  hibernate-entitymanager-5.0.4.Final.jar
  hibernate-java8-5.0.4.Final.jar
  hibernate-jpa-2.1-api-1.0.0.Final.jar
  </code></pre>
  
  <p>For the record, here is my persistence.xml, packaged in my WAR file in
      /WEB-INF/classes/META-INF/persistence.xml</p>
  
  <pre><code>&lt;version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" version="2.1"&gt;
  
      &lt;persistence-unit name="AdminPersistenceUnit"&gt;
          &lt;provider&gt;org.hibernate.jpa.HibernatePersistenceProvider&lt;/provider&gt;
          &lt;properties&gt;
              &lt;property name="hibernate.connection.url" value="jdbc:oracle:thin:@//########:1521/xe"/&gt;
              &lt;property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver"/&gt;
              &lt;property name="hibernate.connection.username" value="#########"/&gt;
              &lt;property name="hibernate.connection.password" value="#########"/&gt;
              &lt;property name="hibernate.archive.autodetection" value="class"/&gt;
              &lt;property name="hibernate.show_sql" value="true"/&gt;
              &lt;property name="hibernate.format_sql" value="true"/&gt;
              &lt;property name="hbm2ddl.auto" value="update"/&gt;
          &lt;/properties&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>And finally, here is the place where I use the entityManager:</p>
  
  <pre><code>public class AdminDatabaseWebservice {
      @PersistenceContext(name = "AdminPersistenceUnit")
      protected EntityManager entityManager;
  }
  </code></pre>
  
  <p>Any help will be highly appreciated!</p>