8 Replies Latest reply on Nov 6, 2017 9:07 AM by simplex-software

    Fail to create data-source with jboss-cli

    simplex-software

      Greetings,

       

      I'm using Wildfly 10.1.0.Final on Ubuntu 16.4. I'm trying to create an Oracle JDBC data-source using the jboss-cli tool. First, I create the required module:

       

      # Add Oracle module

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

       

      This works as expected and the following directory structure is created:

       

      --modules

      ----oracle

      ------jdbc

      --------main

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

      ----------ojdbc6.jar

      ----system

      ------layers

      --------base

      ...........................

       

      And the content of the module.xml file is:

       

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

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

          <resources>

              <resource-root path="ojdbc6.jar"/>

          </resources>

          <dependencies>

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

          </dependencies>

      </module>

       

      All these seems ok. Now I add the Oracke JDBC driver:

      # Add Oracle JDBC driver

      /subsystem=datasources/jdbc-driver=oracle:add(driver-name=oracle, driver-module-name=oracle.jdbc, driver-xa-datasource-class-name=oracle.jdbc.xa.client.OracleXADataSource)

       

      This raises the following exception:

       

      2017-11-03 12:32:48,800 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 14) WFLYCTL0013: Operation ("add") failed - address: ([

          ("subsystem" => "datasources"),

          ("jdbc-driver" => "oracle")

      ]): java.util.ServiceConfigurationError: java.sql.Driver: Provider oracle.jdbc.OracleDriver could not be instantiated

      at java.util.ServiceLoader.fail(ServiceLoader.java:232)

      at java.util.ServiceLoader.access$100(ServiceLoader.java:185)

      at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:384)

      at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)

      at java.util.ServiceLoader$1.next(ServiceLoader.java:480)

      at org.jboss.as.connector.subsystems.datasources.JdbcDriverAdd.performRuntime(JdbcDriverAdd.java:107)

      at org.jboss.as.controller.AbstractAddStepHandler.performRuntime(AbstractAddStepHandler.java:337)

      at org.jboss.as.controller.AbstractAddStepHandler$1.execute(AbstractAddStepHandler.java:151)

      at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:890)

      at org.jboss.as.controller.AbstractOperationContext.processStages(AbstractOperationContext.java:659)

      at org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:370)

      at org.jboss.as.controller.OperationContextImpl.executeOperation(OperationContextImpl.java:1329)

      at org.jboss.as.controller.ModelControllerImpl.internalExecute(ModelControllerImpl.java:400)

      at org.jboss.as.controller.ModelControllerImpl.execute(ModelControllerImpl.java:222)

      at org.jboss.as.controller.remote.ModelControllerClientOperationHandler$ExecuteRequestHandler.doExecute(ModelControllerClientOperationHandler.java:208)

      at org.jboss.as.controller.remote.ModelControllerClientOperationHandler$ExecuteRequestHandler.access$300(ModelControllerClientOperationHandler.java:130)

      at org.jboss.as.controller.remote.ModelControllerClientOperationHandler$ExecuteRequestHandler$1$1.run(ModelControllerClientOperationHandler.java:152)

      at org.jboss.as.controller.remote.ModelControllerClientOperationHandler$ExecuteRequestHandler$1$1.run(ModelControllerClientOperationHandler.java:148)

      at java.security.AccessController.doPrivileged(Native Method)

      at javax.security.auth.Subject.doAs(Subject.java:422)

      at org.jboss.as.controller.AccessAuditContext.doAs(AccessAuditContext.java:149)

      at org.jboss.as.controller.remote.ModelControllerClientOperationHandler$ExecuteRequestHandler$1.execute(ModelControllerClientOperationHandler.java:148)

      at org.jboss.as.protocol.mgmt.AbstractMessageHandler$ManagementRequestContextImpl$1.doExecute(AbstractMessageHandler.java:363)

      at org.jboss.as.protocol.mgmt.AbstractMessageHandler$AsyncTaskRunner.run(AbstractMessageHandler.java:472)

      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

      at java.lang.Thread.run(Thread.java:748)

      at org.jboss.threads.JBossThread.run(JBossThread.java:320)

      Caused by: java.lang.NoClassDefFoundError: javax/management/InstanceAlreadyExistsException

      at java.lang.Class.getDeclaredConstructors0(Native Method)

      at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)

      at java.lang.Class.getConstructor0(Class.java:3075)

      at java.lang.Class.newInstance(Class.java:412)

      at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380)

      ... 25 more

      Caused by: java.lang.ClassNotFoundException: javax.management.InstanceAlreadyExistsException from [Module "oracle.jdbc:main" from local module loader @ba4d54 (finder: local module finder @12bc6874 (roots: /home/nicolas/wildfly-10.1.0.Final/modules,/home/nicolas/wildfly-10.1.0.Final/modules/system/layers/base))]

      at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)

      at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)

      at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)

      at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)

      ... 30 more

       

      Obviously, for some reason, the Oracle module is not found. Notice that it appears in modules/oracle, so outside modules/system/layers/base, but well, it was created by the CLI command, so I reckon that this is where it should be created.

      What am I donig wrong here ?

      Many thanks in advance,

      Nicolas

        • 1. Re: Fail to create data-source with jboss-cli
          jaikiran

          The module is being found, but it's missing a dependency on the javax.api module. Edit the module.xml of your Oracle driver module to include this dependency, in addition to what you have:

           

          <dependencies>

          .....

                  <module name="javax.api"/>

          ....

          • 2. Re: Fail to create data-source with jboss-cli
            simplex-software

            Hi,

             

            I modified the module.xml file such that to read:

             

            <?xml version='1.0' encoding='US-ASCII'?>

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

                <resources>

                    <resource-root path="ojdbc6.jar"/>

                </resources>

                <dependencies>

                    <module name="javax.api"/>

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

                </dependencies>

            </module>

             

            Now, the command:

             

            /subsystem=datasources/jdbc-driver=oracle:add(driver-name=oracle, driver-module-name=com.oracle, driver-xa-datasource-class-name=oracle.jdbc.xa.client.OracleXADataSource)

             

            raises:

             

            2017-11-04 17:12:51,273 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 2) WFLYCTL0013: Operation ("add") failed - address: ([

                ("subsystem" => "datasources"),

                ("jdbc-driver" => "oracle")

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

             

            Any other suggestion ?

            • 3. Re: Fail to create data-source with jboss-cli
              lafr

              Module's name has changed from oracle.jdbc to com.oracle.

              Where's the module located now? Still in modules/oracle/jdbc or moved to modules/com/oracle?

              • 4. Re: Fail to create data-source with jboss-cli
                rhn-support-abhati

                Hi,

                 

                Please confirm the module location , if your ojdbc6.jar is present in com.oracle module then your directory structure should be :

                 

                EAP_HOME/modules/com/oracle/main/ojdbc6.jar and module.xml should also be present in this location.

                 

                Please check if your jar is downloaded from a official webnsite , this issue is also observed if you are using a corrupt jar file.

                 

                Please try to download ojdbc7.jar from oracle website and try to configure and test your data source.

                • 5. Re: Fail to create data-source with jboss-cli
                  simplex-software

                  Hello Frank,

                   

                  Thanks for your response. Yes, the module's name has changed as trying tones of stuff in order to get things working, I found an example using this naming convention. So here is my file-system hierarchy:

                   

                  [jboss@e628f5a7a92e main]$ pwd

                  /opt/jboss/wildfly/modules/com/oracle/main

                  [jboss@e628f5a7a92e main]$ ll

                  total 2108

                  -rw-rw-r-- 1 jboss jboss     266 Nov  4 17:39 module.xml

                  -rw-rw-r-- 1 jboss jboss 2152051 Nov  4 17:10 ojdbc6.jar

                   

                  However I'm still getting the exception:

                   

                  [standalone@localhost:9990 /] /subsystem=datasources/jdbc-driver=oracle:add(driver-name=oracle, driver-module-name=oracle.jdbc, driver-xa-datasource-class-name=oracle.jdbc.xa.client.OracleXADataSource)

                  {

                      "outcome" => "failed",

                      "failure-description" => "WFLYJCA0041: Failed to load module for driver [oracle.jdbc]",

                      "rolled-back" => true

                  }

                  [standalone@localhost:9990 /]

                   

                  Do you see anything here ?

                   

                  Many thanks in advance.

                   

                  Kind regards,

                  Nicolas

                  • 6. Re: Fail to create data-source with jboss-cli
                    mayerw01

                    I made the experiences that it might cause problems to name the module differing from the directory path.

                    So in your case I'd suggest to rename your module to "com.oracle"

                    • 7. Re: Fail to create data-source with jboss-cli
                      simplex-software

                      Hi Wolfgang,

                       

                      Here is the new command:

                       

                      /subsystem=datasources/jdbc-driver=oracle:add(driver-name=com.oracle, driver-module-name=com.oracle, driver-xa-datasource-class-name=oracle.jdbc.xa.client.OracleXADataSource)

                      {

                          "outcome" => "failed",

                          "failure-description" => "WFLYJCA0015: the attribute driver-name (com.oracle) cannot be different from driver resource name (oracle)",

                          "rolled-back" => true

                      }

                      [standalone@localhost:9990 /]

                       

                      And:

                       

                      /subsystem=datasources/jdbc-driver=com.oracle:add(driver-name=com.oracle, driver-module-name=com.oracle, driver-xa-datasource-class-name=oracle.jdbc.xa.client.OracleXADataSource)

                      {

                          "outcome" => "failed",

                          "failure-description" => "WFLYJCA0041: Failed to load module for driver [com.oracle]",

                          "rolled-back" => true

                      }

                      [standalone@localhost:9990 /]

                       

                      The log file doesn't contain any additional information.

                      Kind regards,

                      Nicolas

                      • 8. Re: Fail to create data-source with jboss-cli
                        simplex-software

                        I figured out the problem was. The command:

                         

                        # Add Oracle module

                        module add --name=com.oracle --resources=/opt/jboss/wildfly/customization/ojdbc6.jar --dependencies=[javax.api, javax.transaction.api]

                         

                        used to create the new module was simply wrong. Unfortunatelly, no error message is displayed and, looking at the new module.xml file, one cannot see any problem. But the correct command is:

                         

                        # Add Oracle module

                        module add --name=com.oracle --resources=/opt/jboss/wildfly/customization/ojdbc6.jar --dependencies=javax.api,javax.transaction.api

                         

                        i.e. ommit the brackets around the JSON list and don't leave spaces after the comma. For example: --dependencies=javax.api, javax.transaction.api displays an error message, which has leaded me to try to use brackets, as this is a JSON list. And since no error was raised, I thought that the module creation was successfull. Have wasted several days on such a stupid typo issue !

                         

                        Notice that on Windows, the "[" "]" characters appear in the module.xml file, as opposed to Ubuntu where they don't. In fact, this is how I could find the issue: I tested on Windows and, seeing that the behaviour was the same, I looked in the module.xml file and I saw the syntax problem.