Hi All,
I'm implementing a UserFederationProviderFactory and want to create an
EntityManagerFactory from one of its methods. I have packaged up a persistence.xml in the
META-INF folder of the SPI jar file and deployed this as a module to the keycloak
standalone server.
My module.xml looks like this...
<module xmlns="urn:jboss:module:1.3"
name="acme.keycloak-acme-user-federation">
<resources>
<resource-root path="keycloak-acme-user-federation-1.0.0.jar">
<filter>
<include path="META-INF/**"/>
</filter>
</resource-root>
</resources>
<dependencies>
<module name="org.keycloak.keycloak-core"/>
<module name="org.keycloak.keycloak-server-spi"/>
<module name="javax.api"/>
<module name="javaee.api"/>
<module name="org.hibernate" />
<module name="org.jboss.ws.cxf.jbossws-cxf-client"/>
</dependencies>
</module>
In my UserFederationProviderFactory I have a method like this...
private EntityManagerFactory
getEntityManagerFactory(UserFederationProviderModel model) {
if (emf == null) {
logger.trace("Creating
entityManagerFactory...");
Map<String, String> config =
model.getConfig();
Properties p = new Properties();
// for now just use hibernate built in
connection factory
p.put("hibernate.connection.driver_class",
config.get(DATABASE_DRIVER_CLASS_NAME));
p.put("hibernate.connection.url", config.get(DATABASE_URL));
p.put("hibernate.connection.username", config.get(DATABASE_USER));
p.put("hibernate.connection.password", config.get(DATABASE_PASSWORD));
p.put("hibernate.show_sql",
"true");
p.put("hibernate.format_sql",
"true");
emf =
Persistence.createEntityManagerFactory("acmeEntities", p);
}
return emf;
}
When this method is called, it always returns the error "No Persistence provider for
EntityManager named acmeEntities".
I'm 90% sure this is to do with the ClassLoader being used by Persistence not being
able to see the META-INF/persistence.xml packaged up in the
keycloak-acme-user-federation-1.0.0.jar. Does anyone have an idea what I need to do to my
module configuration to get this working?
Thanks,
Anthony Fryer
The content of this e-mail, including any attachments, is a confidential communication
between Virgin Australia Airlines Pty Ltd (Virgin Australia) or its related entities (or
the sender if this email is a private communication) and the intended addressee and is for
the sole use of that intended addressee. If you are not the intended addressee, any use,
interference with, disclosure or copying of this material is unauthorized and prohibited.
If you have received this e-mail in error please contact the sender immediately and then
delete the message and any attachment(s). There is no warranty that this email is error,
virus or defect free. This email is also subject to copyright. No part of it should be
reproduced, adapted or communicated without the written consent of the copyright owner. If
this is a private communication it does not represent the views of Virgin Australia or its
related entities. Please be aware that the contents of any emails sent to or from Virgin
Australia or its related entities may be periodically monitored and reviewed. Virgin
Australia and its related entities respect your privacy. Our privacy policy can be
accessed from our website:
www.virginaustralia.com