9 Replies Latest reply on Sep 15, 2017 11:36 AM by Jason Glass

    Proper definition of Oracle XA datasource in configuration

    Michael Dinsmore Newbie

      I'm trying to make an XA datasource with Oracle in JBoss 7 (standalone-preview).  I'm getting errors from this (I'll attach the relevant log file at the end of the post) -- saying it can't find the driver-name child.

       

      From my understanding, I need to create the datasource definition in the standalone.xml (or standalone-preview.xml) file.  I first created the Oracle module:

       

      1.  In /modules/com/oracle directory I put the ojdbc6.jar file and created a new file called modules.xml that reads:

       

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

          <resources>

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

          </resources>

          <dependencies>

              <module name="javax.api"/>

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

          </dependencies>

      </module>

       

      2.  In my standalone-preview.xml I added the following section to the xml file (replacing the sample h2 datasource that was there):

       

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

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

                  <datasources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                     xsi:noNamespaceSchemaLocation="http://www.jboss.org/ironjacamar/schema/datasources_1_0.xsd">

                     <xa-datasource jndi-name="ds/MYDATASOURCE" pool-name="ds/MYDATASOURCE"

                        enabled="true" jta="true" use-java-context="true" use-ccm="true">

                        <xa-datasource-property name="URL">jdbc:oracle:thin:@MYSERVER.DOMAIN.COM:1521:MYSCHEMA

                        </xa-datasource-property>

                        <xa-datasource-property name="User">USERNAME</xa-datasource-property>

                        <xa-datasource-property name="Password">PASSWORD</xa-datasource-property>

       

       

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

                        <xa-pool>

                           <is-same-rm-override>false</is-same-rm-override>

                           <no-tx-separate-pools />

                        </xa-pool>

                        <validation>

                           <valid-connection-checker

                              class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"></valid-connection-checker>

                           <stale-connection-checker

                              class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker"></stale-connection-checker>

                           <exception-sorter

                              class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"></exception-sorter>

                        </validation>

                     </xa-datasource>

                     <drivers>

                        <driver name="ojdbc6.jar" module="com.oracle">

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

                        </driver>

                     </drivers>

                  </datasources>

               </subsystem>

       

      I have tried finding an example of an XA datasource for the new JBoss 7 but unable to find one.  I did find some documentation in the IronJacamar web page (http://docs.jboss.org/ironjacamar/userguide/1.0/en-US/html_single/#ex_datasources_oracle_xa) but that seems out of date and incorrect.  It references a note saying to change "pad-true" in transaction.xml but no file of that name exists in JBoss 7.  It also has a reference to <no-tx-separate-pools /> which is incompatible with the XSD when I had it in there -- so I basically don't think I can trust that documentation.

       

      Here's the log file output I get.  It makes it appear as though it's a problem with the xa-datasource xml fragment, not fro mthe driver fragment in my definition:

       

      12:32:13,311 INFO  [org.jboss.modules] JBoss Modules version 1.0.1.GA

      12:32:13,467 INFO  [org.jboss.msc] JBoss MSC version 1.0.0.GA

      12:32:13,506 INFO  [org.jboss.as] JBoss AS 7.0.1.Final "Zap" starting

      12:32:14,132 WARN  [org.jboss.as] No security realm defined for native management service, all access will be unrestricted.

      12:32:14,186 INFO  [org.jboss.as] creating http management service using network interface (management) port (9990)

      12:32:14,188 WARN  [org.jboss.as] No security realm defined for http management service, all access will be unrestricted.

      12:32:14,197 INFO  [org.jboss.as.logging] Removing bootstrap log handlers

      12:32:14,203 ERROR [org.jboss.as.controller] (Controller Boot Thread) Operation ("add") failed - address: ([

          ("subsystem" => "datasources"),

          ("xa-data-source" => "ds/GAPCore")

      ]): java.util.NoSuchElementException: No child 'driver-name' exists

                at org.jboss.dmr.ModelValue.requireChild(ModelValue.java:362)

                at org.jboss.dmr.ObjectModelValue.requireChild(ObjectModelValue.java:298)

                at org.jboss.dmr.ModelNode.require(ModelNode.java:703)

                at org.jboss.as.connector.subsystems.datasources.AbstractDataSourceAdd.performRuntime(AbstractDataSourceAdd.java:87)

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

                at org.jboss.as.controller.OperationContextImpl.executeStep(OperationContextImpl.java:351)

                at org.jboss.as.controller.OperationContextImpl.doCompleteStep(OperationContextImpl.java:298)

       

       

      Any help or pointers to documentation would be much appreciated.

       

      thanks,

      Mike

        • 1. Re: Proper definition of Oracle XA datasource in configuration
          Michael Dinsmore Newbie

          I found my problem(s) -- first, I needed to update/fix the module name to match what I had used in the modules/com/oracle/modules.xml file, so it now reads in my standalone-preview.xml file:

           

             <driver name="ojdbc6.jar" module="com.oracle.db">

           

          and I also have to reference the driver in the <xa-datasource> xml fragment before the <drivers> fragment:

           

             <driver>ojdbc6.jar</driver>

           

          and that ended up pretty much fixing things.

           

          I'm still confused where to put the padding="true" like I used to configure in my older JBoss 4.2.2.  Is that still needed?

          • 2. Re: Proper definition of Oracle XA datasource in configuration
            Michael Dinsmore Newbie

            I spoke too soon... I am still having trouble with the XA Datasource configuration.  I'm surprised I can't seem to find any decent references for how to make this work and what the options are.  Does anyone use an XA Datasource?

             

            I have my configuration as explained above, but as I deploy my application, I see that there's three failing services:

             

            09:08:45,716 ERROR [org.jboss.as] (Controller Boot Thread) JBoss AS 7.0.2.Final "Arc" started (with errors) in 2278ms - Started 133 of 195 services (3 services failed or missing dependencies, 59 services are passive or on-demand)

             

            And using jconsole and looking at the jboss.msc bean, I can inspect the deployed services (dumpServicesToString) and figure out which ones are failing.  Currently, this seems to be the only way to look up and find out what services are failing (but https://issues.jboss.org/browse/AS7-527 will address this).  So my failing services are:

             

            Service "jboss.data-source.java:/ds/Foobar" (class org.jboss.as.connector.subsystems.datasources.XaDataSourceService) mode ACTIVE state DOWN (PROBLEM) (parent: jboss.as.server-controller) (dependencies: jboss.jdbc-driver.registry, jboss.naming, jboss.jdbc-driver.ojdbc6_jar, jboss.connector.transactionintegration, jboss.security.subject-factory, jboss.management_repository, jboss.xa-data-source-config.java:/ds/Foobar) (has unavailable dependency)

             

            Service "jboss.data-source.reference-factory.java:/ds/Foobar" (class org.jboss.as.connector.subsystems.datasources.DataSourceReferenceFactoryService) mode ACTIVE state DOWN (PROBLEM) (parent: jboss.as.server-controller) (dependencies: jboss.data-source.java:/ds/Foobar) (has unavailable dependency)

             

            Service "jboss.naming.context.java.ds.Foobar" (class org.jboss.as.naming.service.BinderService) mode ACTIVE state DOWN (PROBLEM) (parent: jboss.as.server-controller) (dependencies: jboss.data-source.reference-factory.java:/ds/Foobar, jboss.naming.context.java) (has unavailable dependency)

             

            Anyone have any insight on where to look next?

             

            I see other examples of configured Oracle datasources not using the <xa-datasource> configuration, but just the plain vanilla <datasource> confgiration, but then referencing the xa datasource.  I am using the ojdbc6.jar and don't reference the driver class because Stefano Maestri  mentioned in this post http://community.jboss.org/thread/169104 that it isn't necessary.  The example Oracle datasource in that thread is NOT using the <xa-datasource> configuration, but in the <drivers> section it does ask for an XA datasource though:

             

                  <xa-datasource-class>

                      oracle.jdbc.xa.client.OracleXADataSource

                 </xa-datasource-class>

             

             

            Thanks for any help on this.

            • 3. Re: Proper definition of Oracle XA datasource in configuration
              Stefano Maestri Expert

              Hi,

               

              could you please post the full standalone.xml configuration file?

               

               

              regards

              S.

              • 4. Re: Proper definition of Oracle XA datasource in configuration
                Michael Dinsmore Newbie


                Thanks for the response.  See the attached file -- I've changed a few basic things like username/password for obvious reasons.

                 

                Just to note -- it's about 95% the basic vanilla file that comes with the standard 7.0.2 download.  I've added a section for a JMS queue, security domains and the jdbc stuff.

                 

                I should also note that on the web admin console (http://localhost:9990/console/App.html#server/datasources) in the XA Datasources section I do see my datasource listed and it has a gren light/icon for the Enabled? column.  However, I am getting all the error messages and problems from the logs saying there's an error.  I think the admin console is misreporting the datasource availability?

                 

                Testing the datasource with the command like admin tool, it can't seem to find the JNDI name that I use and that also shows up on the web admin console:

                 

                 

                /subsystem=datasources/xa-data-source=java\:\/ds\/Foobar:test-connection-in-pool

                • 5. Re: Proper definition of Oracle XA datasource in configuration
                  Stefano Maestri Expert

                  I'll have a deeper look tomorrow. Can you just try to change the jndi name to java:jboss/<your-favorite-name>.

                  Probably it's not the problem you are experiencing, but it would be useful to me knowing if it generate identical errors.

                   

                  thanks in advance

                  S.

                  • 6. Re: Proper definition of Oracle XA datasource in configuration
                    Michael Dinsmore Newbie

                    Thanks.   I tried making that change and it didn't seem to have any effect.  Same error messages.

                    • 7. Re: Proper definition of Oracle XA datasource in configuration
                      staggerlee Newbie

                      A couple of things...

                       

                      Is your module.xml file pluralized to modules.xml?

                       

                      Secondy, and I'm throwing this out there event thought I'm not sure it will help.... does the module name need to be mirrored in it's directory structure? I see that the module com.oracle.db is in modules/com/oracle, ought it be in modules/com/oracle/db or module/com/oracle/db/main?

                       

                      Give 'er a try.

                      • 8. Re: Proper definition of Oracle XA datasource in configuration
                        Michael Dinsmore Newbie

                        I did have a file called modules.xml and not module.xml.  I can't understand how that happened because I swear I copied some existing example -- I think it must have been from this site (http://javalabor.blogspot.com/2011/08/oracle-datasource-in-jboss-as-7.html) which had subsequently fixed their post, but it was after I had followed the instructions.

                         

                        Thanks for the tip.  I'm surprised I was getting some of the stuff defined and not getting more errors from JBoss startup.  Historically, JBoss just loves to throw out multiple errors messages!

                        • 9. Re: Proper definition of Oracle XA datasource in configuration
                          Jason Glass Newbie

                          Oddly enough, I had the exact same problem.  What fixed it for me was a hint from this solution JBAS010441: Failed to load module for driver [...] in JBoss EAP 6 - Red Hat Customer Portal I just added "<?xml version="1.0" encoding="UTF-8"?>" and the driver deployed.  I have no clue why the Microsoft SQL server module.xml worked without it.  Just wanted to add this to your answer in case someone else has my same problem!