-
1. Re: JBoss 7 multiple data source declarations for multiple applications
cpuffalt May 17, 2012 3:27 PM (in response to kdolan1)If you're using v7.1.x then you can put your datasource declarations in separate -ds.xml files as you did in the past. Unfortunately, it looks like the documentation wasn't updated. The v7.1.0 release notes do mention it under the "Developer Usability Enhancements" section. The only real documentation on this that I can find is in a blog posting unfortunately.
If you need to support earlier versions of v7 or run into the documented limitations with -ds.xml files your best bet is likely to use the command line interface which can be used non-interactively.
Hope this helps.
Corey
Edit: Actually, I stand corrected. The documentation linked above does actually mention deploying datasources as standalone -dx.xml files at the bottom of the page.
-
2. Re: JBoss 7 multiple data source declarations for multiple applications
kdolan1 May 17, 2012 3:28 PM (in response to cpuffalt)Oh thank you! I will try this and report back.
-
3. Re: JBoss 7 multiple data source declarations for multiple applications
wdfink May 18, 2012 5:19 AM (in response to kdolan1)It is recommended to not use such -ds.xml deployment in production as mentioned.
mention it under the "Developer Usability Enhancements" section
Also the way to configure JBoss AS7 goes in the direction to use Web-Admin and CLI interface and not change the XML configuration (ok. some initial configuration are necessary).
I would use the CLI interface for the installer to add datasources, or even other stuff. This ensure also that the changes are validated before applied and you might do this as a batch job which can do this as all-or-nothing.
-
4. Re: JBoss 7 multiple data source declarations for multiple applications
kdolan1 May 18, 2012 3:17 PM (in response to wdfink)Ok, I hear you so I spent most of today removing my -ds.xml files and trying to use the CLI to create my data source. I'm having a horrible experience and still do not have anything working. Can you see what I'm doing wrong?
My CLI Command
At a command prompt I'm executing the following:
jboss-cli.bat --connect controller=myserver:myport --file=mycmds.cli
The "mycmds.cli" file contains the following:
xa-data-source add --name=MyDB --jndi-name=java:jboss/datasources/MyDB --user-name=myName --password=myPassword --driver-name=oracle.jdbc.driver.OracleDriver --xa-datasource-class=oracle.jdbc.xa.client.OracleXADataSource --same-rm-override=false --no-tx-separate-pool=true --check-valid-connection-sql="select count(*) from MYTABLE"
Edit: I should add that I haven't figured out yet how to specify the URL. There is no connection-url parameter for the xa-data-source command.
My original -ds.xml file (from JBoss 4.x) I'm trying to convert to JBoss 7.x contained the following:
<xa-datasource>
<jndi-name>MyDB</jndi-name>
<track-connection-by-tx>true</track-connection-by-tx>
<isSameRM-override-value>false</isSameRM-override-value>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
<!-- The line below is used only for mysql installations. -->
<!--new-connection-sql>set autocommit=1</new-connection-sql-->
<xa-datasource-property name="URL">jdbc:oracle:thin:@localhost:1521:XE</xa-datasource-property>
<xa-datasource-property name="User">myUser</xa-datasource-property>
<xa-datasource-property name="Password">myPassword</xa-datasource-property>
<no-tx-separate-pools />
<check-valid-connection-sql>select count(*) from MYTABLE</check-valid-connection-sql>
</xa-datasource>
Oracle driver (ojdbc14.jar)
I first deployed this as a regular JAR by copying it to the standalone/deployments folder and added a .dodeploy file. It deployed successfully but when I ran my CLI command above, it said "oracle.jdbc.driver.OracleDriver" not installed.
I then tried adding to the jar the java.sql.Driver file (as described in the JBoss documentation) to the JAR thinking this might be the problem. It redeployed successfully but I still received the CLI error message.
Finally, I undeployed the Oracle driver as a regular JAR and added it as a module. I created a modules/oracle/jdbc/main folder, copied the original JAR into this folder and added a module.xml file. The module.xml file contains
<module xmlns="urn:jboss:module:1.1" name="oracle.jdbc">
<resources>
<resource-root path="ojdbc14.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
I restarted JBoss, retried my CLI command and received the same error message. I also tried changing the driver name from "oracle.jdbc.driver.OracleDriver" to "oracle.jdbc" and "ojdbc14.jar". In both cases, I still receive the CLI error message "XXX is not installed".
Ultimately, I'm fine setting up Oracle as a module (vs. deployment) because I must also support MySQL and I found in the JBoss documentation it must be configured as a module because it's "is jdbc compliant" method always returns false or something like that. Since I must configure that as a module, I might as well be consistent w/ Oracle.
Thanks!
Kelly
-
5. Re: JBoss 7 multiple data source declarations for multiple applications
shadowcreeper May 30, 2012 2:55 PM (in response to kdolan1)It sounds like you haven't setup your driver correctly.
In standalone/configuration/standalone.xml (or domain or whatever you are using) there is a subsystem node with {code:xml}<datasources><datasource jndi-name=...>{code} (you may build an entry for your datasource here which should use the name mentioned later -- likely {code:xml}<driver>ORACLE</driver>{code}) there should also be (in that same subsystem node) {code:xml}<datasources><drivers><driver>{code} nodes (at least one should already exist by default with name="h2", you now need to add one with name="ORACLE" or whatever you prefer -- to be used in the above {code:xml}<datasources><datasource><driver>{code} node).
Note: The name attribute may not work if you put punctuation marks in it as some of those appear to be treated special (like ".").
-
6. Re: JBoss 7 multiple data source declarations for multiple applications
kdolan1 May 30, 2012 3:03 PM (in response to shadowcreeper)I thought about and believe I tried that w/ no luck. Specifically, I edited my standalone.xml file, added the following and then restarted JBoss before trying the CLI command again.
<drivers>
...
<driver name="oracle" module="oracle.jdbc">
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
</driver>
</drivers>
The CLI command for xa-data-source still did not work. I tried providing "oracle", "oracle.jdbc", and "oracle.jdbc.OracleDriver" as names. I was expecting "oracle" to work.
-
7. Re: JBoss 7 multiple data source declarations for multiple applications
shadowcreeper May 30, 2012 3:09 PM (in response to kdolan1)Pick one or the other ("driver-class" or "xa-datasource-class") as I don't think you can have both in the same driver definition.
And yes, I too would expect "oracle" to be the correct one.
-
8. Re: JBoss 7 multiple data source declarations for multiple applications
kdolan1 May 30, 2012 3:16 PM (in response to shadowcreeper)Thanks! I'll try that and post back.
One small detail that was mentioned in my lengthy list of details was the fact that with the CLI command for xa-data-source I could find no way to provide the URL connection. In the original *-ds.xml file, this was specified as
<xa-datasource-property name="URL">jdbc:oracle:thin:@localhost:1521:XE</xa-datasource-property>
But with the CLI command I could not find its corresponding option. There is a connection URL option/parameter for the regular data-source CLI command, but not one for the XA version. Any ideas?
-
9. Re: JBoss 7 multiple data source declarations for multiple applications
shadowcreeper May 30, 2012 3:24 PM (in response to kdolan1)I'm not using xa-datasource, so your mileage may differ, but I provide that in the datasource definition via the <connection-url>jdbc:....</connection-url> node.
{code:xml}
<datasources>
<datasource jndi-name="java:/jboss/datasources/MyDS"
pool-name="MyDS"
enabled="true"
use-java-context="true">
<connection-url>@database.url@</connection-url>
<driver>@database.driver@</driver>
<pool>
<min-pool-size>100</min-pool-size>
<max-pool-size>200</max-pool-size>
</pool>
<security>
<user-name>@database.username@</user-name>
<password>@database.password@</password>
</security>
<statement>
<prepared-statement-cache-size>100</prepared-statement-cache-size>
<share-prepared-statements>true</share-prepared-statements>
</statement>
</datasource>
</datasources>
{code}
The @database.*@ lines obviously need to be replaced with your database setup.
EDIT: Oh right, you mean via the cli tool... I just created my datasource xml by hand.
-
10. Re: JBoss 7 multiple data source declarations for multiple applications
kdolan1 May 30, 2012 4:36 PM (in response to shadowcreeper)For <xa-datasource>, the connection URL is configured as <xa-datasource-property name="URL">@db.url@</xa-datasource-property>. The CLI options do not seem to provide a way to specify the connection URL as that specifically or as a property name/value. I tried providing the connection-url parameter that is supported by the CLI data-source command but it didn't like it.