0 Replies Latest reply on Jul 29, 2015 12:08 PM by JS Bournival

    The correct way of preferring JPA 2.1 over 2.0 in EAP 6.4.0

    JS Bournival Newbie

      Hi I searched for a solution for this problem without having success so far.


      We're migrating our aplications over to EAP 6.4.0, and our applications relies on JPA 2.1.  However, JBoss is a JEE 6 server, and therefore includes JPA 2.0 in the form of a module.


      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.


      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.


      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


      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


      I tried removing the jpa subsystem from the standalone.xml.


      All of these things resulted in the JPA 2.0 jar being used.


      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.


      Is there a way to do this correctly (without migrating to another server nor changing the code)?