[keycloak-user] Additional jpaConnectionProvider for UserFederation via database

Stian Thorgersen sthorger at redhat.com
Wed Jan 6 09:18:15 EST 2016


Are you deploying it as a module or by dropping it into
standalone/configuration/providers? The latter will pick up the
persistence.xml from Keycloak classloader so that's probably why it doesn't
work. Try deploying as a module instead as that's the only way you can get
full control of the classpath

On 6 January 2016 at 01:00, Harold Campbell <hcamp at muerte.net> wrote:

> On Wed, 2015-11-11 at 14:12 +0100, Stian Thorgersen wrote:
> > At the moment when the provider is specified in keycloak-server.json
> > we only load that one provider. If you only need to use the
> > EntityManagerFactory within your user federation provider you don't
> > need a JpaConnectionProvider at all. Just create the
> > EntityManagerFactory within your UserFederationProviderFactory.
>
> I'm trying to do exactly that, but can't for the life of me get the
> EntityManagerFactory to create. It fails with:
>
> Caused by: javax.persistence.PersistenceException: No Persistence provider
> for EntityManager named XXXXX
>
> Before that, I also see this warning even if I explicitly pass the
> suggested provider as a property:
>
> 17:43:57,250 WARN  [org.hibernate.ejb.HibernatePersistence] (default
> task-53) HHH015016: Encountered a deprecated
> javax.persistence.spi.PersistenceProvider
> [org.hibernate.ejb.HibernatePersistence]; use
> [org.hibernate.jpa.HibernatePersistenceProvider] instead.
>
> The persistence.xml is in META-INF. I also tried META-INF/classes/META-
> INF.
>
> My init code:
>
>         private void lazyInit() {
>                 Map<String, Object> props = new HashMap<>();
>                 props.put(AvailableSettings.PROVIDER,
> "org.hibernate.jpa.HibernatePersistenceProvider");
>                 props.put(AvailableSettings.TRANSACTION_TYPE,
> "RESOURCE_LOCAL");
>                 props.put("jboss.as.jpa.managed", "false");
>                 emFactory =
> Persistence.createEntityManagerFactory("XXXXX", props);
>         }
>
> This same persistence unit works just fine when bundled on it's own
> within a normal JEE EAR.
>
> Any idea what I'm doing wrong? Keycloak 1.7.0.Final
>
> --
> Harold Campbell
>
>         A farmer with extremely prolific hens posted the following sign.
> "Free
> Chickens.  Our Coop Runneth Over."
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-user/attachments/20160106/8adb09fd/attachment.html 


More information about the keycloak-user mailing list