Search code examples
javajpajbossclassloaderear

How can I deploy JPA 2 applications on JBoss SOA 5.x?


I am working on migrating an application originally written using EJB3 persistence (JPA 1.0) on JBoss SOA server version 5.2 so that it uses type safe queries and criteria queries from JPA 2.0 (Hibernate Implementation). So far, I have been completely unable to get the EAR to deploy because it cannot find the proper version of the javax.persistence libraries. The error shows that it cannot find the class javax.persistence.criteria.Expression. From what I can see it is loading the javax.persistence classes from the ejb3-persistence library which is built into JBoss. I have tried various methods which are supposed to cause JBoss to use the application libraries first, but to no avail. Any help would be appreciated.

Methods I have tried:

  1. Adding a "<loader-repository>" configuration to the jboss-app.xml file
  2. Adding a jboss-classloading.xml file to the EAR's META-INF folder
  3. Modifying the ear-deployer-jboss-beans.xml file to use isolated classes.

Solution

  • The answer is that the "jboss-classloading.xml" file will work for web application, but there is no way to override the classloading for EJBs which are published. The libraries for published EJBs have to be unique at the server level and since JBoss aleady includes a library which handles the java.persistence.* namespace, you cannot use any other versions of JPA in EJBs.