abhi3232
abhi3232

Reputation: 391

JBoss : Not able to add datasouce

I am trying to add datasource for IBM DB2 database and it is showing below error

ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 2) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "DB2DS1")
]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.db2"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
    "org.wildfly.data-source.DB2DS1 is missing [jboss.jdbc-driver.db2]",
    "jboss.driver-demander.java:/DB2DS1 is missing [jboss.jdbc-driver.db2]"
]
}

I have below configuration in module.xml which is placed along with database driver in EAP-7.1.0\modules\system\layers\base\com\ibm\db2\main location

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.5" name="com.ibm.db2">
<properties>
    <property name="jboss.api" value="unsupported"/>
</properties>

<resources>
    <resource-root path="db2jcc.jar"/>
</resources>
<dependencies>
    <module name="javax.api"/>
    <module name="javax.transaction.api"/>
    <module name="javax.servlet.api" optional="true"/>
</dependencies>

Also I think I have successfully installed driver as module because I am seeing it's entry in standalone.xml like

   <drivers>
        <driver name="h2" module="com.h2database.h2">
            <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
        </driver>
        <driver name="db2" module="com.ibm.db2">
           <datasource-class>com.ibm.db2.jcc.DB2Driver</datasource-class>
        </driver>
   </drivers>

What thing I am missing here ?.

To add datasource I am hitting below command from CLI

data-source add --name=DB2DS1--jndi-name=java:/DB2DS1--driver-name=db2  --connection-url=jdbc:db2://localhost:50000/sample

Upvotes: 1

Views: 2603

Answers (1)

abhi3232
abhi3232

Reputation: 391

It was a silly mistake I did...

Below is the correct configuration that should be there in standalone.xml

 <drivers>
    <driver name="h2" module="com.h2database.h2">
        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
    </driver>
    <driver name="db2" module="com.ibm.db2">
       <driver-class>com.ibm.db2.jcc.DB2Driver</driver-class>
    </driver>
</drivers>

For simplicity I have followed below steps to add db2 datasource

  1. Created module.xml as mentioned in above question

  2. Added database driver for datasource

/subsystem=datasources/jdbc-driver=ibmdb2:add(driver-name=ibmdb2,driver-module-name=com.ibm.db2,driver-class-name=com.ibm.db2.jcc.DB2Driver)

  1. Added datasource to subsystem

data-source add --name=DB2_EFTDEVS1 --driver-name=ibmdb2 --driver-class=com.ibm.db2.jcc.DB2Driver --user-name=Administrator --password=Test#123 --connection-url=jdbc:db2://localhost:50000/sample --jndi-name="java:jboss/datasources/DB2_EFTDEVS1"

Upvotes: 3

Related Questions