title: ClassCastException with OpenJPA in Jboss 6.0
body: <p>Jboss 6 comes with JPA 2.0 (<code>hibernate-jpa-2.0-api.jar</code>) and Hibernate 3.6.6 as the implementation.</p>
  <p>I have a web application that has OpenJPA 2.0 library (openjpa-all-2.1.0.jar). I have set the classloader isolation in the jboss-web.xml as shown below</p>
  <pre><code>&lt;class-loading java2ClassLoadingCompliance=&quot;false&quot;&gt;
      &lt;loader-repository&gt;
          some.example:loader=some-webapp.war
          &lt;loader-repository-config&gt;java2ParentDelegation=false&lt;/loader-repository-config&gt;
      &lt;/loader-repository&gt;
  &lt;/class-loading&gt;
  </code></pre>
  <p>When I deploy the application I get this error</p>
  <blockquote>
  <p>ERROR [AbstractKernelController] Error installing to Start: name=persistence.unit:unitName=some.war#some state=Create: java.lang.ClassCastException: org.apache.openjpa.persistence.PersistenceProviderImpl cannot be cast to javax.persistence.spi.PersistenceProvider</p>
  </blockquote>
  <p>This is strange since, <code>org.apache.openjpa.persistence.PersistenceProviderImpl</code> already implements <code>javax.persistence.spi.PersistenceProvider</code></p>
  <p>I did a <code>-version:class</code> to check where the <code>javax.persistence.spi.PersistenceProvider</code> is being loaded from and it appears that it's being loaded from the web application first and then from <code>jboss6\common\lib</code></p>
  <blockquote>
  <p>[Loaded javax.persistence.spi.PersistenceProviderResolverHolder$1 from vfs:/home/sathwik/apps/jboss-6.1.0.Final/server/default/deploy/some-webapp.war/WEB-INF/lib/openjpa-all-2.1.0.jar/]</p>
  <p>[Loaded javax.persistence.spi.PersistenceProvider from vfs:/home/sathwik/apps/jboss-6.1.0.Final/common/lib/hibernate-jpa-2.0-api.jar/]</p>
  </blockquote>
  <p>From the <code>Manifest.mf</code> file i was able to gather the JDK version used to compile
  <code>hibernate-jpa-2.0-api.jar</code> is compiled with <code>Build-Jdk: 1.5.0_19</code>,
  <code>openjpa-all-2.1.0</code> is compiled with <code>Build-Jdk: 1.6.0_22</code></p>
  <p>Can anyone help me out in understanding why this exception?</p>