thanos keske
thanos keske

Reputation: 63

Keycloak integration with Mysql 8.0

I am trying to connect keycloak 12 with mysql 8.0. First of all I made the dev changes on windows machine and everything is perfect. Now, I am trying to implement it on ubuntu 20.04. The changes are:

            <datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" enabled="true" use-java-context="true">
                <connection-url>jdbc:mysql://localhost:3306/keycloak?useSSL=false&amp;characterEncoding=UTF-8&amp;useJDBCCompliantTimezoneShift=true&amp;useLegacyDatetimeCode=false&amp;serverTimezone=UTC</connection-url>
                <driver>mysql</driver>
                <pool>
                    <max-pool-size>20</max-pool-size>
                </pool>
                <security>
                    <user-name>root</user-name>
                </security>
                <validation>
                    <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
                    <validate-on-match>true</validate-on-match>
                    <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
                </validation>
            </datasource>
            <drivers>
                <driver name="mysql" module="com.mysql">
                    <xa-datasource-class>com.mysql.cj.jdbc.MysqlXADataSource</xa-datasource-class>
                </driver>
                <driver name="h2" module="com.h2database.h2">
                    <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                </driver>
            </drivers>

the first timne I start the service it's all perfect and liquibase of keycloak creates all 94 tables of database. After service's restart I have thw following error.

2021-02-08 21:17:37,092 FATAL [org.keycloak.services] (ServerService Thread Pool -- 68) Error during startup: java.lang.RuntimeException: Exception invoking method [listUnrunChangeSets] on object [liquibase.Liquibase@226434d1], using arguments [null,(),false]
    at [email protected]//org.keycloak.common.util.reflections.Reflections.invokeMethod(Reflections.java:385)
    at [email protected]//org.keycloak.connections.jpa.updater.liquibase.LiquibaseJpaUpdaterProvider.getLiquibaseUnrunChangeSets(LiquibaseJpaUpdaterProvider.java:285)
    at [email protected]//org.keycloak.connections.jpa.updater.liquibase.LiquibaseJpaUpdaterProvider.validateChangeSet(LiquibaseJpaUpdaterProvider.java:253)

Thanks a lot

Upvotes: 1

Views: 2388

Answers (2)

anjnkmr
anjnkmr

Reputation: 868

I have faced the same issue, I resolved it by downgrading the MySQL connector driver version to 8.0.22.

Based on this post: https://bugs.mysql.com/bug.php?id=102435, It is the intended behaviour from version 8.0.23

Upvotes: 3

psytester
psytester

Reputation: 244

Yes it is and it looks like next upcoming keycloak release will have a fix for that issue, refer to keycloak pr #7942

Upvotes: 1

Related Questions