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. We only use the JpaConnectionProvider as we have multiple providers using the same EntityManagerFactory.

On 29 October 2015 at 13:57, Matuszak, Eduard <eduard.matuszak@atos.net> wrote:
Hello
 
I am trying to implement a userfederation-provider based on a jpa-connection. My approach was:
 
According to an additional datasource-defintion for  the federated DB in the standalone.xml
 
                <datasource jta="true" jndi-name="java:jboss/datasources/CCPDS" pool-name="CCPDS" enabled="true" use-ccm="true">
                    <connection-url>jdbc:oracle:thin:@servername:1521:schemaname</connection-url>
..
 
, I tried to register this datasource as an additional connectionJpa-entry in keycloak-server.json as follows:
 
..
    "connectionsJpa": {
        "default": {
            "dataSource": "java:jboss/datasources/CCPKCDS",
            "databaseSchema": "update"
        },
        "FED-DB": {
            "dataSource": "java:jboss/datasources/CCPDS"
        }
    },
..
 
According to these configuration I hoped to be able to establish the appropriate entity manager by coding:
 
        // Get the appropriate entity manager from the KeycloakSession
        EntityManager em = session.getProvider(JpaConnectionProvider.class, "FED-DB").getEntityManager();
 
This did not work, indeed there is still only one (default) JpaConnectionProvider available in the session (JpaConnectionProviderList size is 1):
 
        Set<JpaConnectionProvider> JpaConnectionProviderList = session.getAllProviders(JpaConnectionProvider.class);
 
My question is: isn’t it in principle possible to register a second jpaConnector additionally to the default one or is there something missing or wrong in my approach?
 
Thanks for any help in advance.
 
Best regards, Eduard Matuszak
 
Dr. Eduard Matuszak
 
Worldline, an atos company
Max-Stromeyer-Straße 116
78467 Konstanz
Germany
 
 
Worldline GmbH
Geschäftsführer: Wolf Kunisch
Aufsichtsratsvorsitzender: Christophe Duquenne
Sitz der Gesellschaft: Frankfurt/Main
Handelsregister: Frankfurt/Main HRB 40 417

* * * * * * * * L E G A L D I S C L A I M E R * * * * * * * *
This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this e-mail by error, please notify the sender immediately and destroy it. As its integrity cannot be secured on the internet, the Atos group liability cannot be triggered for the message content. Although the sender endeavors to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and shall not be liable for any damages resulting from any virus transmitted.
* * * * * * * * L E G A L D I S C L A I M E R * * * * * * * *
 
 
 
 

_______________________________________________
keycloak-user mailing list
keycloak-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/keycloak-user