Understanding JDBC configuration in JBoss
mark.drummond Jul 25, 2014 1:50 PMHello everyone,
JBoss newb here. I'm deploying EA 6.2.4 on RHEL 6.5. EAP is installed from the RH repos (/usr/share/jbossas). I have one master and two slaves. I've completed the first JBoss admin course, and I have a reasonable amount of experience with WebSphere Application Server (Network Deployment) and some Tomcat experience.
I'm having a heck of time trying to understand JBDC driver installation and data source configuration. It may well be just me but I find the official docs sorely lacking in useful detail. Example code and commands are nice but there's no explanation of how things actually work, so the errors I get are largely meaningless to me.
I'm trying to install the IBM DB2 JDBC v4 driver (DB2 9.7). This is what I have done so far:
0. On all three hosts (master + two slaves):
1. Created /usr/share/jbossas/modules/com/ibm/main/
2. Drop db2jcc4.jar into main/, along with db2jcc_license_cu.jar
3. Created the following modules.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.ibm">
<resources>
<resource-root path="db2jcc4.jar"/>
<resource-root path="db2jcc_license_cu.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
4. Ran the following from the CLI on the master (I assume this is exactly the same if I run the CLI from a slave but tell it to connect to the master):
[domain@10.10.220.177:9999 /] /profile=full/subsystem=datasources/jdbc-driver=db2jcc4:add(driver-name=db2jcc4,driver-module-name="com.ibm")
(command output has since been lost)
[domain@10.10.220.177:9999 /] /profile=full/subsystem=datasources/jdbc-driver=db2jcc4:read-resource(recursive=true)
{
"outcome" => "success",
"result" => {
"deployment-name" => undefined,
"driver-class-name" => undefined,
"driver-datasource-class-name" => undefined,
"driver-major-version" => undefined,
"driver-minor-version" => undefined,
"driver-module-name" => "com.ibm",
"driver-name" => "db2jcc4",
"driver-xa-datasource-class-name" => undefined,
"jdbc-compliant" => undefined,
"module-slot" => undefined,
"xa-datasource-class" => undefined
}
}
Q. Does the above look correct? It looks like the driver is installed, and if I try using the data source configuration wizard from the console, it shows up in the list of recognized drivers. But I have a lot of undefined attributes.
Q. The above command was run against a specific profile. Is it the case that a driver is always associated with a profile, and if I want to use the same driver with server-groups created with some other profile, I need to run the same command against that profile? The answer seems to be yes but again, not understanding how things work under the hood, I'd appreciate confirmation from someone more knowledgeable than me.
Assuming the driver was installed, I tried setting up a data source from the CLI and the console. Results from the CLI:
[domain@10.10.220.177:9999 /] /profile=full/subsystem=datasources/data-source=IndexDB:add(jndi-name=java:/indexdb,connection-url=jdbc:db2://[MYDBFQDN]:50011/iblindex,driver-name=db2jcc4,user-name=[MYDBUSERNAME],password=[MYDBPASSWORD])
{
"outcome" => "failed",
"result" => undefined,
"failure-description" => "JBAS010839: Operation failed or was rolled back on all servers.",
"rolled-back" => true,
"server-groups" => {
"eidc-dev-group-1" => {"host" => {"kgneapdv02" => {"eidc-dev-server-1" => {"response" => {
"outcome" => "failed",
"result" => undefined,
"rolled-back" => true
}}}}},
"fastandfull-dev-group-1" => {"host" => {"kgneapdv01" => {"fastandfull-dev-server-1" => {"response" => {
"outcome" => "failed",
"result" => undefined,
"rolled-back" => true
}}}}},
"fatca-dev-group-1" => {"host" => {"kgneapdv01" => {"fatca-dev-server-1" => {"response" => {
"outcome" => "failed",
"result" => undefined,
"failure-description" => {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.driver-demander.java:/indexdb is missing [jboss.jdbc-driver.db2jcc4]"]},
"rolled-back" => true
}}}}},
"fg-iam-dev-group-1" => {"host" => {"kgneapdv01" => {"fg-iam-dev-server-1" => {"response" => {
"outcome" => "failed",
"result" => undefined,
"failure-description" => {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.driver-demander.java:/indexdb is missing [jboss.jdbc-driver.db2jcc4]"]},
"rolled-back" => true
}}}}}
}
}
Failures across the board, but oddly, the second two server groups provide a failure-description while the first two do not.
Q. Is the above error meaningful to anyone? Google and RH support have so far not been able to help.
Again, a data source appears to be associated with a profile, as opposed to a server-group or individual application. This seems to indicate that if I have a data source that I want only available to a single application, I need to create a profile for that application, and a server-group from that profile. Not really understanding the architectural decisions, this doesn't make much sense to me, and creating a new profile seems painful given there is no capability (yet) to clone a profile from the CLI. I assume the easiest way to do this is to cut and past in the domain.xml file, but that involves restarting the DC. Red Hat has an example CLI batch script for doing this but that script fails.
Sorry for the long-winded post. In the end, I am just trying to understand how these pieces really go together.
Thanks,
Mark