-
1. Re: EAR Classloader not finding PersistenceProvider class inside packaged WAR
white_crow Jun 1, 2017 10:14 AM (in response to white_crow)Meanwhile i've refactored our structure a little bit, so that now I have several ejb-jars and one war inside a ear. The persistence unit mentioned in my previous post, is now inside of an ejb-jar.
I could finally run it, but only if I use the parameter:
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
As soon as i change it to true, I get the ClassNotFoundException again, which in a way also makes sense, but can't I just selectively export some stuff of an ejb-jar without having to set this parameter to false?
Thanks
-
2. Re: EAR Classloader not finding PersistenceProvider class inside packaged WAR
smarlow Jun 6, 2017 2:06 PM (in response to white_crow)The Class Loading in WildFly documentation may be helpful to you.
-
3. Re: EAR Classloader not finding PersistenceProvider class inside packaged WAR
white_crow Jun 7, 2017 2:58 AM (in response to smarlow)Thanks for your reply
If you look at my post, I've already put in the same link (AS7 instead of Wildfly though) and quoted something from there.
To me it's still unclear, what classes inside an EJB-JAR or WAR can be seen by the EAR classloader or where I've even the chance to define so.
-
4. Re: EAR Classloader not finding PersistenceProvider class inside packaged WAR
smarlow Jun 8, 2017 3:13 PM (in response to white_crow)The JPA persistence provider is not part of the persistence unit, so the rules for loading the persistence unit do not apply to loading the persistence provider. Have you tried moving the persistence provider (CustomPersistenceProvider) to the EAR/lib folder, I would expect that to help with the loading of the custom persistence provider.
Also, it is the JPA container that reads the persistence.xml file, not the persistence provider.
-
5. Re: EAR Classloader not finding PersistenceProvider class inside packaged WAR
white_crow Jun 9, 2017 3:31 AM (in response to smarlow)Thanks for your reply
I haven't tried it to move it to the EAR/lib folder yet, since I was not sure, since that JAR also contains EJBs and I was not sure, if that would work in the EAR/lib.
I finally managed to get it to work, if I put
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
into the jboss-deployment-structure.xml
What also came to my mind, but haven't tried it yet, maybe the right way would be having a META-INF/services file as follows:
META-INF/services/javax.persistence.spi.PersistenceProvider
with content: foo.bar.YourCustomPersistenceProvider
Maybe that way, it would be found, even if the isolation is switched on.
-
6. Re: EAR Classloader not finding PersistenceProvider class inside packaged WAR
smarlow Jun 9, 2017 8:59 AM (in response to white_crow)If you run into further difficulties, you could upgrade to the latest WildFly version and if that doesn't help, you could then request enhancements to better support your application.
https://github.com/wildfly/wildfly/blob/master/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jpa/mockprovider/classtransformer/ClassFileTransformerTestCase.java is a (minimal) unit test that includes a mock persistence provider (Java proxy based implementation that ignores most methods) that you might find interesting, as it is in a EAR/lib jar with the META-INF/services file included. This unit test was added to an AS 8.x release and is still present in the latest WildFly release. The purpose of the unit test isn't really to ensure that your particular applications works, but more for ensuring that entity class transformers work as designed. However, you may still find it interesting.
Scott