0

I'm attempting to use a custom provider in persistence.xml (actually, just creating a thin facade in front of the Hibernate Provider in order to capture audit data).

I've changed the persistence.xml to look like (based on a similar stackoverflow post here)

The relevant portion of the file now looks like

<persistence-unit name="oauth2server-ds">
  <!-- <provider>org.hibernate.ejb.HibernatePersistence</provider> -->
  <provider>psu.edu.javaee.audit.producer.MyHibernatePersistenceProvider</provider>
  <jta-data-source>java:jboss/datasources/oauth2server-ds</jta-data-source>

I've verified that the class psu.edu.javaee.audit.producer.MyHibernatePersistenceProvider is in the .war I'm deploying, but I still get a

Caused by: javax.persistence.PersistenceException: JBAS011466: PersistenceProvider 'psu.edu.javaee.audit.producer.MyHibernatePersistenceProvider' not found

Is there anything additional I need to do to make this class visible on the classpath? I'm on wildfly-8.2.0-Final if that has any relevance.

Shawn Eion Smith
  • 417
  • 4
  • 18
  • The here href didn't work, the previous post I based this on is at http://stackoverflow.com/questions/25553048/how-can-i-intercept-jta-transactions-events-and-get-a-reference-to-the-current-e – Shawn Eion Smith Aug 24 '15 at 20:44
  • Can you try to put your class into a separate jar library and include it within application server shared libraries instead of within your application archive? I have a feeling that the problem is in classloading mechanism used by Wildfly. – OndroMih Aug 25 '15 at 14:47

1 Answers1

0

The answer turned out to be adding a services directory in the META-INF directory and inside the services directory add a file called javax.persistence.spi.PersistenceProvider that contains the fully qualified name of the the replacement persistence provider. Thanks to Alex H. for the help.

So, META-INF/services/javax.persistence.spi.PersistenceProvider with the fully qualified name of the replacement provider.

Shawn Eion Smith
  • 417
  • 4
  • 18