7 Replies Latest reply on Jun 13, 2019 9:08 AM by shaun_leo

    Wildfly 16: Module not loading for datasource

    shaun_leo

      Error on start up:

      [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 48) WFLYCTL0013: Operation ("add") failed - address: ([
       ("subsystem" => "datasources"),
       ("jdbc-driver" => "oracle")
       - failure description: "WFLYJCA0041: Failed to load module for driver [oracle.jdbc]"



      Contents of module.xml file:

      <?xml version="1.0" encoding="UTF-8"?>

      <module xmlns="urn:jboss:module:1.5" name="oracle.jdbc">

          <resources>

              <resource-root path="ojdbc7-12.1.0.2.jar"/>

          </resources>

          <dependencies>

              <module name="javax.api"/>

              <module name="javax.transaction.api"/>

          </dependencies>

      </module>

       

       

      Datasources subsystem configuration in standalone-full-ha.xml:

              <subsystem xmlns="urn:jboss:domain:datasources:5.0">

                  <datasources>

                      <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true" statistics-enabled="${wildfly.datasources.statistics-enabled:${wildfly.statistics-enabled:false}}">

                          <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>

                          <driver>h2</driver>

                          <security>

                              <user-name>sa</user-name>

                              <password>sa</password>

                          </security>

                      </datasource>

                      <datasource jndi-name="java:jboss/datasources/OracleDS" pool-name="OracleDS" enabled="true" use-java-context="true" use-ccm="true">

                          <connection-url>jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = myserver.domain.name)(PORT = 8685)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ORADS)))</connection-url>

                          <driver>oracle</driver>

                          <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>                   

                          <pool>

                              <min-pool-size>5</min-pool-size>

                              <max-pool-size>50</max-pool-size>

                              <prefill>true</prefill>

                          </pool>

                          <security>

                              <user-name>myusername</user-name>

                              <password>mysecret</password>

                          </security>

                          <timeout>

                              <set-tx-query-timeout>true</set-tx-query-timeout>

                              <blocking-timeout-millis>30000</blocking-timeout-millis>

                              <idle-timeout-minutes>30</idle-timeout-minutes>

                              <query-timeout>0</query-timeout>

                              <use-try-lock>0</use-try-lock>

                              <allocation-retry>0</allocation-retry>

                              <allocation-retry-wait-millis>0</allocation-retry-wait-millis>

                          </timeout>

                      </datasource>

                      <drivers>

                          <driver name="h2" module="com.h2database.h2">

                              <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>

                          </driver>

                          <driver name="oracle" module="oracle.jdbc">

                              <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>

                          </driver>

                      </drivers>

                  </datasources>

              </subsystem>



      I have checked several times to verify that the module.xml and the ojdbc7.jar file are in the location: /opt/jboss/wildfly/modules/oracle/jdbc/main/. Moving them to /opt/jboss/wildfly/modules/system/layers/base/oracle/jdbc/main/ does not help.
      I also have verified that the javax dependencies listed in the module.xml are not missing. I will appreciate any help finding the cause of the error. Thanks.

        • 1. Re: Wildfly 16: Module not loading for datasource
          jaikiran

          shaun_leo  wrote:

           

          Error on start up:

          [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 48) WFLYCTL0013: Operation ("add") failed - address: ([  ("subsystem" => "datasources"),  ("jdbc-driver" => "oracle")  - failure description: "WFLYJCA0041: Failed to load module for driver [oracle.jdbc]"



          Contents of module.xml file:

          <?xml version="1.0" encoding="UTF-8"?>

          <module xmlns="urn:jboss:module:1.5" name="oracle.jdbc">

              <resources>

                  <resource-root path="ojdbc7-12.1.0.2.jar"/>

              </resources>

              <dependencies>

                  <module name="javax.api"/>

                  <module name="javax.transaction.api"/>

              </dependencies>

          </module>

           

           



          I have checked several times to verify that the module.xml and the ojdbc7.jar file are in the location: /opt/jboss/wildfly/modules/oracle/jdbc/main/. Moving them to /opt/jboss/wildfly/modules/system/layers/base/oracle/jdbc/main/ does not help.


          Place the jar file in the modules/system/layers/base/oracle/jdbc/main and make sure you call the jar file ojdbc7-12.1.0.2.jar because that's what it's called in your module.xml

          • 2. Re: Wildfly 16: Module not loading for datasource
            shaun_leo

            The ojdbc jar file is indeed named just like the module.xml. Placing the module under modules/system/layers/base does not fix the error.

            Actually, I was getting this problem deploying my application in a Wildfly Docker container. So I tried deploying it in a regular (non-containerized) Wildfly 16 server. It loaded the database driver module without any errors and also created the datasource successfully. I cannot see any difference between the Docker container setup and the regular setup. Here are the contents of Dockerfile which builds the container.

            FROM jboss/wildfly:16.0.0.Final


            #cluster config and other standalone changes

            COPY standalone-full-ha.xml /opt/jboss/wildfly/standalone/configuration/

             

            COPY war/target/my-app.war /opt/jboss/wildfly/standalone/deployments/

             

            #jdbc driver

            RUN mkdir -p /opt/jboss/wildfly/modules/system/layers/base/oracle/jdbc/main

            COPY ojdbc7-12.1.0.2.jar /opt/jboss/wildfly/modules/system/layers/base/oracle/jdbc/main/

            COPY jdbc-module.xml /opt/jboss/wildfly/modules/system/layers/base/oracle/jdbc/main/module.xml

             

            #json-simple for splunk

            RUN mkdir -p /opt/jboss/wildfly/modules/system/layers/base/com/googlecode/json-simple/main

            COPY json-simple-1.1.1.jar /opt/jboss/wildfly/modules/system/layers/base/com/googlecode/json-simple/main/

            COPY google-json.xml /opt/jboss/wildfly/modules/system/layers/base/com/googlecode/json-simple/main/module.xml

             

            #splunk-logging

            RUN mkdir -p /opt/jboss/wildfly/modules/system/layers/base/com/splunk/logging/main

            COPY espn-splunk-library-javalogging-1.5.3-RC1.jar /opt/jboss/wildfly/modules/system/layers/base/com/splunk/logging/main/

            COPY splunk-module.xml /opt/jboss/wildfly/modules/system/layers/base/com/splunk/logging/main/module.xml

             

            #active mq

            COPY activemq-rar.rar /opt/jboss/wildfly/standalone/deployments/

             

            #create admin user

            RUN /opt/jboss/wildfly/bin/add-user.sh admin admin --silent

            EXPOSE 8080 9990 8787 8088





            • 3. Re: Wildfly 16: Module not loading for datasource
              mayerw01

              You should place the files under

              $JBOSS_HOME/modules/com/oracle/main and your module.xml should look like:

              <module xmlns="urn:jboss:module:1.3" name="com.oracle">

              ...

              • 4. Re: Wildfly 16: Module not loading for datasource
                shaun_leo

                The ojdbc jar have does not have a `com` directory.
                dir structure of ojdbc jar

                • 5. Re: Wildfly 16: Module not loading for datasource
                  mayerw01

                  The driver module name does not reflect the path to the driver but to the driver file.
                  The path to the driver is taken from the <driver-class> entry.

                  So I'd suggest that you add such an entry.

                  Usually you should be safe if you add the driver via cli as documented in JDBC Driver / DataSource Setup · HAL Management Console

                  • 6. Re: Wildfly 16: Module not loading for datasource
                    jaikiran

                    I don't see a reason why it should behave different with this container. You might want to "get into" the running container (typically through the use of something like "docker exec -it <container-id> bash") and browse around the directories and files to really ensure the file is indeed there and with the right set of permissions.

                    • 7. Re: Wildfly 16: Module not loading for datasource
                      shaun_leo

                      Strangely after I swapped the driver jar I had with the ojdbc7.jar from here the issue with docker container was fixed. The jdbc jar I originally had was working fine with Wildfly16 server outside of a docker container. I did verify that the module descriptor and jar were inside the correct directory within the running container. So I could not determine the cause of the problem but I'm glad I'm past the issue. Thanks all for the helpful replies.