[keycloak-user] adding mysql or mariadb backend

Andrew Meyer andrewm659 at yahoo.com
Thu Mar 21 23:09:47 EDT 2019


 Yes, I took a look at this.  Followed what was in the examples and still am getting the following:
Mar 21 22:03:54 saml01 standalone.sh: at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)Mar 21 22:03:54 saml01 standalone.sh: at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)Mar 21 22:03:54 saml01 standalone.sh: at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)Mar 21 22:03:54 saml01 standalone.sh: at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)Mar 21 22:03:54 saml01 standalone.sh: at io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:596)Mar 21 22:03:54 saml01 standalone.sh: at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:97)Mar 21 22:03:54 saml01 standalone.sh: at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:78)Mar 21 22:03:54 saml01 standalone.sh: ... 8 moreMar 21 22:03:54 saml01 standalone.sh: Caused by: java.lang.RuntimeException: Failed to connect to databaseMar 21 22:03:54 saml01 standalone.sh: at org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.getConnection(DefaultJpaConnectionProviderFactory.java:382)Mar 21 22:03:54 saml01 standalone.sh: at org.keycloak.connections.jpa.updater.liquibase.lock.LiquibaseDBLockProvider.lazyInit(LiquibaseDBLockProvider.java:65)Mar 21 22:03:54 saml01 standalone.sh: at org.keycloak.connections.jpa.updater.liquibase.lock.LiquibaseDBLockProvider.lambda$waitForLock$0(LiquibaseDBLockProvider.java:97)Mar 21 22:03:54 saml01 standalone.sh: at org.keycloak.models.utils.KeycloakModelUtils.suspendJtaTransaction(KeycloakModelUtils.java:678)Mar 21 22:03:54 saml01 standalone.sh: at org.keycloak.connections.jpa.updater.liquibase.lock.LiquibaseDBLockProvider.waitForLock(LiquibaseDBLockProvider.java:95)Mar 21 22:03:54 saml01 standalone.sh: at org.keycloak.services.resources.KeycloakApplication$1.run(KeycloakApplication.java:148)Mar 21 22:03:54 saml01 standalone.sh: at org.keycloak.models.utils.KeycloakModelUtils.runJobInTransaction(KeycloakModelUtils.java:227)Mar 21 22:03:54 saml01 standalone.sh: at org.keycloak.services.resources.KeycloakApplication.<init>(KeycloakApplication.java:141)Mar 21 22:03:54 saml01 standalone.sh: at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)Mar 21 22:03:54 saml01 standalone.sh: at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)Mar 21 22:03:54 saml01 standalone.sh: at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)Mar 21 22:03:54 saml01 standalone.sh: at java.lang.reflect.Constructor.newInstance(Constructor.java:423)Mar 21 22:03:54 saml01 standalone.sh: at org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:152)Mar 21 22:03:54 saml01 standalone.sh: ... 31 moreMar 21 22:03:54 saml01 standalone.sh: Caused by: javax.naming.NameNotFoundException: datasources/KeycloakDS [Root exception is java.lang.IllegalStateException]Mar 21 22:03:54 saml01 standalone.sh: at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:153)Mar 21 22:03:54 saml01 standalone.sh: at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:83)Mar 21 22:03:54 saml01 standalone.sh: at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207)Mar 21 22:03:54 saml01 standalone.sh: at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:184)Mar 21 22:03:54 saml01 standalone.sh: at org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:239)Mar 21 22:03:54 saml01 standalone.sh: at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:193)Mar 21 22:03:54 saml01 standalone.sh: at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:189)Mar 21 22:03:54 saml01 standalone.sh: at javax.naming.InitialContext.lookup(InitialContext.java:417)Mar 21 22:03:54 saml01 standalone.sh: at javax.naming.InitialContext.lookup(InitialContext.java:417)Mar 21 22:03:54 saml01 standalone.sh: at org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.getConnection(DefaultJpaConnectionProviderFactory.java:375)Mar 21 22:03:54 saml01 standalone.sh: ... 43 more


Here is the command that I am running.  I don't understand what I am doing wrong.
[root at saml01 current]# sudo -u keycloak ./bin/jboss-cli.sh 'module add --name=com.jdbc.mysql --resources=mysql-connector-java-5.1.47.jar --dependencies=javax.api,javax.xml.bind.api'Module com.jdbc.mysql already exists at /opt/keycloak/5.0.0/modules/com/jdbc/mysql/main[root at saml01 current]# 


I ran all of the commands as shown in the example and keycloak still fails to start.


    On Thursday, March 21, 2019, 7:03:12 AM CDT, Vlasta Ramik <vramik at redhat.com> wrote:  
 
 Hello,

you can take a look at 
https://github.com/keycloak/keycloak/blob/cf35a4648bcb93aaf1ac63918ee5c4b0f422d7d5/testsuite/integration-arquillian/servers/auth-server/jboss/common/jboss-cli/configure-server-jpa.cli 
for inspiration.

V.

On 3/19/19 9:43 PM, Andrew Meyer wrote:
> Hello,If I am adding a mariadb or mysql backend to keycloak v4.8.3 or 5.0.0 what is the correct syntax from the jboss-cli.sh tool?   This is what I have in my notes.
> Open the Jboss CLI and add the MySQL driver (you don't have to connect with the Jboss websocket).
> $ ./bin/jboss-cli.sh Is this the correct mysql connector version for MariaDB 10.1.x?MySQL/MariaDBjboss-cli$ module add --name=com.mysql  --dependencies=javax.api,javax.transaction.api --resources=/root/mysql-connector-java-5.1.47.jar
>
> Add the Database driver to the configuration.
> MySQL/MariaDB# sudo su -
> Is this the correct syntax for the driver?  Should it be com.mysql or org.mysql??
> $ sudo -u keycloak ./bin/jboss-cli.sh 'embed-server,/subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql,driver-module-name=com.mysql,driver-class-name=com.mysql.jdbc.Driver)'
>
> Remove the h2 KeycloakDS data source and add the MySQL KeycloakDS data source. (Don't delete the test database and change YOURPASS to something random)
> MySQL/MariaDB
> # sudo su -$ sudo -u keycloak ./bin/jboss-cli.sh 'embed-server,/subsystem=datasources/data-source=KeycloakDS:remove'
> $ sudo -u keycloak ./bin/jboss-cli.sh 'embed-server,/subsystem=datasources/data-source=asmDS:add(driver-name=com.mysql,enabled=true,use-java-context=true,connection-url="jdbc:mysql://10.150.10.20:3306/keycloak?useSSL=false&amp;useLegacyDatetimeCode=false&amp;serverTimezone=America/Chicago&amp;characterEncoding=UTF-8",jndi-name="java:/jboss/datasources/KeycloakDS",user-name=keycloak,password="ChangeMe",valid-connection-checker-class-name=org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker,validate-on-match=true,exception-sorter-class-name=org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker)'
> $ sudo -u keycloak ./bin/jboss-cli.sh 'embed-server,/subsystem=datasources/data-source=asmDS:test-connection-in-pool'
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user
  


More information about the keycloak-user mailing list