user353829
user353829

Reputation: 1434

Oracle DB Connection: failure description: "WFLYJCA0041: Failed to load module for driver [com.oracle]

Setting up connection to Oracle19C from Keycloak 12.0.3

Receiving message: "failure description: "WFLYJCA0041: Failed to load module for driver [com.oracle]"

I've relooked x100 and can't seem to find what is missing. Could any kind soul review the below for what I have missed?

JAR File path: /modules/system/layers/keycloak/com/oracle/main module.xml ojdbc10.jar

standalone.xml

<datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" enabled="true" use-java-context="true" statistics-enabled="${wildfly.datasources.statistics-enabled:${wildfly.statistics-enabled:false}}">
        <connection-url>jdbc:oracle:thin:@DBURL:1521:SID</connection-url>
        <driver>oracle</driver>
        <pool>
            <min-pool-size>5</min-pool-size>
            <max-pool-size>100</max-pool-size>
            <prefill>true</prefill>
            <flush-strategy>IdleConnections</flush-strategy>
        </pool>
        <security>
            <user-name>USER</user-name>
            <password>PASSWORD</password>
        </security>
        <validation>
            <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/>
            <check-valid-connection-sql>select 1 from dual</check-valid-connection-sql>
            <background-validation>true</background-validation>
            <stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker"/>
            <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/>
        </validation>
        <timeout>
            <blocking-timeout-millis>5000</blocking-timeout-millis>
            <idle-timeout-minutes>5</idle-timeout-minutes>
        </timeout>
    </datasource>
    <driver name="oracle" module="com.oracle">
            <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
            <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
        </driver>

module.xml

 <?xml version=”1.0" ?><?xml version='1.0' encoding='UTF-8'?>
 <module xmlns=”urn:jboss:module:1.3" name=”com.oracle”>
 <resources>
 <resource-root path=”ojdbc10.jar”/>
 </resources>
 <dependencies>
 <module name=”javax.api”/>
 <module name=”javax.transaction.api”/>
 </dependencies>
</module>

Upvotes: 2

Views: 5216

Answers (2)

Paul Snow
Paul Snow

Reputation: 91

I had this issue, and the only way I could solve it was to place the oracle driver in the keycloak/modules directory.

These did not work:

  • keycloak/modules/system/layers/keycloak/com/oracle It is here that is described in the KeyCloak documentation, and it worked for me for Postgres, but I could not get the oracle driver to load from here.
  • keycloak/modules/system/layers/base/com/oracle : Tried this out of desperation.

But this worked for me in:

  • keycloak/modules/com/oracle

keycloak/modules/com/oracle/main/module.xml

<?xml version='1.0' encoding='UTF-8'?>
<module xmlns="urn:jboss:module:1.1" name="com.oracle">
    <resources>
        <resource-root path="ojdbc8.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>
</module>

And the ojdbc8.jar file was also in this directory.

NOTE: The name="com.oracle" has to match the path com/oracle in the module directory.

In the standalone.xml file, I added the following datasource.

<datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" enabled="true" use-java-context="true">
    <connection-url>jdbc:oracle:thin:@hostname:1521:SID</connection-url>
    <driver>oraclejdbc</driver>
    <pool>
            <min-pool-size>1</min-pool-size>
            <max-pool-size>20</max-pool-size>
    </pool>
    <security>
            <user-name>user</user-name>
            <password>password</password>
    </security>
</datasource>

With the matching driver

<driver name="oraclejdbc" module="com.oracle">
    <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
    <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
</driver>

NOTE:

  • the module="com.oracle" matches the path com/oracle.
  • the driver name="oraclejdbc" matches the <driver>oraclejdbc</driver> element.

Once working, I saws this in the log.

2021-05-31 14:46:17,376 INFO  [org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory] (ServerService Thread Pool -- 60) Database info: {databaseUrl=jdbc:oracle:thin:@server:1521:SID, databaseUser=user, databaseProduct=Oracle Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production
Version 19.10.0.0.0, databaseDriver=Oracle JDBC driver 19.3.0.0.0}

But prior to it working I would see the following errors in the log (which I am including, incase people are googling the error message)

2021-05-31 14:47:12,049 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 50) WFLYCTL0013: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("jdbc-driver" => "oraclejdbc")
]) - failure description: "WFLYJCA0115: Module for driver [com.oracle] or one of it dependencies is missing: [com.oracle]"

Or this error

2021-05-31 14:47:14,962 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("data-source" => "KeycloakDS")
]) - failure description: {
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.oraclejdbc"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => [
        "org.wildfly.data-source.KeycloakDS is missing [jboss.jdbc-driver.oraclejdbc]",
        "jboss.driver-demander.java:jboss/datasources/KeycloakDS is missing [jboss.jdbc-driver.oraclejdbc]"
    ]
}

Upvotes: 4

user353829
user353829

Reputation: 1434

Adde module via commandline.

module add --name=oracle.jdbc --resources=customization/ojdbc10.jar --dependencies=javax.transaction.api

Created under the following structure:

-keycloak

--modules

----oracle

------jdbc

--------main

----------module.xml

----------ojdbc10.jar

Upvotes: 1

Related Questions