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:
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 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.
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.
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
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:
with content: foo.bar.YourCustomPersistenceProvider
Maybe that way, it would be found, even if the isolation is switched on.
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.