persistence.xml in module not read
trispad Aug 17, 2015 10:49 AMHi All,
I am writing a custom Keycloak user federation module. I have followed the instructions from Keycloak to implement the WildFly module. The module is picked up by Keycloak and executed, but it does not see the persistence.xml in the module/jar.
Here is where my module is placed:
modules/com/
`-- cbm
`-- my
`-- my-user-federation
`-- main
|-- module.xml
|-- module.xml~
`-- my-user-federation-1.0-SNAPSHOT.jar
Here is my jar:
my-user-federation-1.0-SNAPSHOT/
|-- com
| `-- cbm
| `-- my
| `-- keycloak
| |-- MyKeycloakUser.class
| |-- MyUserFederationProvider.class
| |-- MyUserFederationProviderFactory$1.class
| `-- MyUserFederationProviderFactory.class
`-- META-INF
|-- MANIFEST.MF
|-- maven
| `-- com.cbm.my
| `-- my-user-federation
| |-- pom.properties
| `-- pom.xml
|-- persistence.xml
`-- services
`-- org.keycloak.models.UserFederationProviderFactory
This is the exception I am getting:
Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named my-user-federation
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:61)
when call the following code in 'MyUserFederationProviderFactory':
Map<String, Object> properties = new HashMap<String, Object>(); properties.put(AvailableSettings.NON_JTA_DATASOURCE, dataSource); properties.put("hibernate.show_sql", config.getBoolean("showSql", false)); properties.put("hibernate.format_sql", config.getBoolean("formatSql", false)); logger.info("Creating My-User-Federation EntityManagerFactory"); entityManagerFactory = Persistence.createEntityManagerFactory("my-user-federation",properties);
( I followed this as an example to create my EntityManagerFactory keycloak/DefaultJpaConnectionProviderFactory.java at master · keycloak/keycloak · GitHub)
I am going to be self-managing the transactions as they are read-only and the objects are not instantiated by the 'container' but by Keycloak.
I have debugged through, and the Keycloak persistence.xml is being picked up, but the one from my module. I would prefer to not do straight JDBC.
I am working with WF-9.0.1 and Keycloak 1.4.0
Thanks for any help/ideas,
Tristan