title: Using JPA 2.1 in EAP 6.4.0
body: <p>I searched for a solution for this problem without having success so far.</p>
  
  <p>We're migrating our aplications over to EAP 6.4.0, and our applications relies on JPA 2.1.  However, JBoss is a Java EE 6 server, and therefore includes JPA 2.0 in the form of a module.</p>
  
  <p>I tried including the JPA API jar directly in my WEB-INF/lib directory, thinking the classloader would prefer this one over the one from the system.</p>
  
  <p>I have tried to include a jboss-deployment-structure.xml file in my ear.  I tried it under ear/META-INF, ear/war/META-INF, and ear/war/WEB-INF.</p>
  
  <p>In the jboss-deployment-structure.xml file, I tried to:
  exclude the javax.persistence.api module
  create my own module with JPA 2.1 and add a dependency to it
  exclude the jpa subsystem</p>
  
  <p>I also tried to set the export attribute to false in the javax.persistence.api module.xml file located under jboss-eap-6.4.0\modules\system\layers\base\javax\persistence\api\main</p>
  
  <p>I tried removing the jpa subsystem from the standalone.xml.</p>
  
  <p>All of these things resulted in the JPA 2.0 jar being used.  </p>
  
  <p>The only way I got it to work was to replace the actual jar in the module directory (jboss-eap-6.4.0\modules\system\layers\base\javax\persistence\api\main).  But that's not a valid solution as other apps or services in the server may actually need the old version of the API.</p>
  
  <p>Is there a way to do this correctly (without migrating to another server nor changing the code)?</p>