6 Replies Latest reply on Jun 9, 2017 8:59 AM by Scott Marlow

    EAR Classloader not finding PersistenceProvider class inside packaged WAR

    Reto Hodel Newbie

      Hello there


      I'm currently trying to pack our web application (WAR) inside an EAR - For the moment we only have this one sub-module. Inside the WAR, there is a JAR in the WEB-INF/lib folder which contains a custom implementation of PersistenceProvider. Also we have a persistence.xml file in this JAR's META-INF folder. So it basically looks something as follows:








      ------------------persistence.xml (listing CustomPersistenceProvider as provider)



      However, when trying to deploy the EAR, it complains about not finding CustomPersistenceProvider (ClassNotFoundException at org.jboss.modules.ModuleClassLoader.findClass). According to the documentation, JPA 2.0, chapter 8.2, it should be perfectly fine, having the persistence.xml in a JAR inside the WEB-INF/lib folder of a WAR. And it also seems to find the persistence.xml, because he knows which class he has to look for. But it does not seem to see classes inside the WAR. In chapter 8.2.2 it also states, that when a persistence unit is defined at the level of a WAR, it is also scoped like that - but does this count for the EAR itself as well?


      I further found something in this docu Class Loading in AS7 - JBoss AS 7.0 - Project Documentation Editor where it says the following "The ear-subdeployments-isolated element value has no effect on the isolated classloader of the .war file(s). i.e. irrespective of whether this flag is set to true or false, the .war within a .ear will have an isolated classloader and other sub-deployments within that .ear will not be able to access classes from that .war. This is as per spec."


      So I guess it's a more general question: Can the EAR module classloader not see classes defined in one of its sub-deployments (eg WAR)? I know that communication between sub-deployments has to be explicitly defined or shared classes should be in a lib folder of the EAR.


      What would be the best solution, without having to change the WAR (eg moving classes around), because we're still using it as standalone WAR?