[keycloak-user] Configuring MySQL JDBC Driver with Keycloak-5.0.0

Jan Lieskovsky jlieskov at redhat.com
Thu Apr 11 13:51:08 EDT 2019


Hello Karasawa-san,

On Thu, Apr 11, 2019 at 7:08 PM Mizuki Karasawa <kmizuki88 at yahoo.com> wrote:

> Hi,
> Has anyone successfully load MySQL JDBC driver with Keycloak-5.0.0?
> Following
> https://www.keycloak.org/docs/5.0/server_installation/index.html#_database
> , it should be straightforward, but I'm getting error when Keycloak starts:
>
> 2019-04-10 14:08:12,055 ERROR
> [org.jboss.as.controller.management-operation] (ServerService Thread Pool
> -- 28) WFLYCTL0013: Operation ("add") failed - address: ([
>     ("subsystem" => "datasources"),
>     ("jdbc-driver" => "mysql")
> ]) - failure description: "WFLYJCA0041: Failed to load module for driver
> [org.mysql]"
> This can be reproduced after driver is configured, before configuring
> datasource 'KeycloakDS' to user the JDBC driver, following are the steps
> that i followed:
>
> 1. yum install mysql-connector-java
>
> 2. mkdir -p /opt/keycloak/modules/system/layers/keycloak/org/mysql/main/
>
> 3. cd /opt/keycloak/modules/system/layers/keycloak/org/mysql/main/
>
> 4. ln -s /usr/share/java/mysql-connector-java.jar ./
>
> 5. cat << EOF > module.xml<?xml version="1.0" encoding="UTF-8"?>
> <module xmlns="urn:jboss:module:1.3" name="org.mysql">
>   <resources>
>     <resource-root path="mysql-connector-jav.jar" />
>

I think you have a typo here -- missing the 'a' character before the .jar
suffix:

# rpm -ql mysql-connector-java | grep jar
/usr/share/java/mysql-connector-java.jar


>   </resource>
>   <dependencies>
>     <module name="javax.api"/>
>     <module name="javax.transaction.api"/>
>   </dependencies>
> </module>
> EOF
>
> 6. Declare the driver in
> /opt/keycloak/standalone/configuration/standalone.xml , add the driver to
> the <drivers> section:
> <drivers>   ....
>    <driver name="mysql" module="org.mysql">
>       <driver-class>org.mysql.jdbc.Driver</driver-class>
>    </driver></drivers>
> 7. restart Keycloak
>
> Note that changing to various JDBC drivers doesn't make a difference, just
> to test the driver itself is fine, I connect to localhost console via
> http://localhost:9990, and loaded the driver as the new deployment, and
> configured the datasource to use the driver seems to be working fine.
> Does anyone have suggestions what is possibly going on?
>

HTH


>
> Thanks a lot!
> Mizuki
>

Jan


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> <?xml version="1.0" encoding="UTF-8"?><module xmlns="urn:jboss:module:1.3"
> name="org.mysql">  <resources>    <resource-root
> path="mysql-connector-java-bin.jar" />  </resource>  <dependencies>
> <module name="javax.api"/>    <module name="javax.transaction.api"/>
> </dependencies></module>EOF
>
> - Add JDBC driver type to
> '/opt/keycloak/standalone/configuration/standalone.xml' in <datasources>
> block as followng:
>                 <drivers>                    <driver name="h2"
> module="com.h2database.h2">
> <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
>               </driver>                    <driver name="mysql"
> module="org.mysql">
> <driver-class>org.mysql.jdbc.Driver</driver-class>
> </driver>                </drivers>
> Before I change actual 'KeyclockDS' datasource to use MySQL, I restart the
> service to confirm the JDBC driver is successfully load, but I got
> following error:
> 2019-04-10 14:08:12,055 ERROR
> [org.jboss.as.controller.management-operation] (ServerService Thread Pool
> -- 28) WFLYCTL0013: Operation ("add") failed - address: ([    ("subsystem"
> => "datasources"),    ("jdbc-driver" => "mysql")]) - failure description:
> "WFLYJCA0041: Failed to load module for driver [org.mysql]"
> _______________________________________________
> 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