9 Replies Latest reply on May 2, 2008 12:46 PM by Vicky Kak

    JBAS-4662 Implementation details.

    Vicky Kak Master

      There will be *LOT* of applications which would have configured XADataSource property in non javabean convention , the sample xa-ds.xml also contain the same pattern .
      To make this JIRA changes having no impact on such configurations I am thinking of providing a configurable property in xa ds.xml file which will decide if the javabean convention needs to be followed .
      This flag should be enabled explicitly in the ds.xml file as

      <java-bean-convention/>

      If we don't do this way then we might land up in explaining this to most of our USERS which we would not like to do now :(
      Also we might land up in changing/testing all the sample xa-ds.xml file.



        • 1. Re: JBAS-4662 Implementation details.
          Vicky Kak Master

           

          "vickyk" wrote:
          If we don't do this way then we might land up in explaining this to most of our USERS which we would not like to do now :(

          Stupid analysis here , my bad :(
          We don't need it , all we need is to change the first character to upper case if it is not entered in UpperCase . Right now we are forcing the user to enter the first character of the property in uppercase.


          • 2. Re: JBAS-4662 Implementation details.
            Vicky Kak Master

            I don't see the type ha-local-tx-datasource/ha-xa-datasource being handled by Jboss5 , I realized this when I stated porting JBAS-4662 to Jboss5 .

            Is anyone working towards this ?

            • 3. Re: JBAS-4662 Implementation details.
              Vicky Kak Master

              A quick changes on my local system got it working

              [vicky@localhost connector]$ svn diff
              Index: src/main/org/jboss/resource/metadata/mcf/ManagedConnectionFactoryDeploymentGroup.java
              ===================================================================
              --- src/main/org/jboss/resource/metadata/mcf/ManagedConnectionFactoryDeploymentGroup.java (revision 71222)
              +++ src/main/org/jboss/resource/metadata/mcf/ManagedConnectionFactoryDeploymentGroup.java (working copy)
              @@ -61,7 +61,8 @@
               @XmlElement(name="no-tx-datasource", type=NoTxDataSourceDeploymentMetaData.class),
               @XmlElement(name="xa-datasource", type=XADataSourceDeploymentMetaData.class),
               @XmlElement(name="no-tx-connection-factory", type=NoTxConnectionFactoryDeploymentMetaData.class),
              - @XmlElement(name="tx-connection-factory",type=TxConnectionFactoryDeploymentMetaData.class)})
              + @XmlElement(name="tx-connection-factory",type=TxConnectionFactoryDeploymentMetaData.class),
              + @XmlElement(name="ha-local-tx-datasource",type=HALocalDataSourceDeploymentMetaData.class)})
               private List<ManagedConnectionFactoryDeploymentMetaData> deployments = new ArrayList<ManagedConnectionFactoryDeploymentMetaData>();
              
               /** The services */
              Index: src/main/org/jboss/resource/deployers/ManagedConnectionFactoryParserDeployer.java
              ===================================================================
              --- src/main/org/jboss/resource/deployers/ManagedConnectionFactoryParserDeployer.java (revision 71232)
              +++ src/main/org/jboss/resource/deployers/ManagedConnectionFactoryParserDeployer.java (working copy)
              @@ -40,12 +40,14 @@
               import org.jboss.resource.metadata.mcf.LocalDataSourceDeploymentMetaData;
               import org.jboss.resource.metadata.mcf.NoTxDataSourceDeploymentMetaData;
               import org.jboss.resource.metadata.mcf.TxConnectionFactoryDeploymentMetaData;
              +import org.jboss.resource.metadata.mcf.HALocalDataSourceDeploymentMetaData;
               import org.jboss.resource.metadata.repository.JCAMetaDataRepository;
               import org.jboss.resource.deployers.management.LocalDSInstanceClassFactory;
               import org.jboss.resource.deployers.management.NoTxCFInstanceClassFactory;
               import org.jboss.resource.deployers.management.NoTxInstanceClassFactory;
               import org.jboss.resource.deployers.management.TxInstanceClassFactory;
               import org.jboss.resource.deployers.management.XADSInstanceClassFactory;
              +import org.jboss.resource.deployers.management.HALocalDSInstanceClassFactory;
               import org.jboss.virtual.VirtualFile;
               import org.jboss.managed.api.ManagedObject;
               import org.jboss.managed.api.ManagedProperty;
              @@ -93,6 +95,7 @@
               moFactory.setInstanceClassFactory(NoTxDataSourceDeploymentMetaData.class, new NoTxInstanceClassFactory());
               moFactory.setInstanceClassFactory(TxConnectionFactoryDeploymentMetaData.class, new TxInstanceClassFactory());
               moFactory.setInstanceClassFactory(NoTxConnectionFactoryDeploymentMetaData.class, new NoTxCFInstanceClassFactory());
              + moFactory.setInstanceClassFactory(HALocalDataSourceDeploymentMetaData.class, new HALocalDSInstanceClassFactory());
               }
              
               /**
              


              • 4. Re: JBAS-4662 Implementation details.
                Adrian Brock Master

                The ha behaviours have been rolled into the main jdbc resource adapters.

                You should NOT need to handle it specially.

                You do not need seperate metadata for the ha case (it is now just an alias in the xml
                for backwards compatiblity).

                • 5. Re: JBAS-4662 Implementation details.
                  Vicky Kak Master

                   

                  "adrian@jboss.org" wrote:

                  You do not need seperate metadata for the ha case (it is now just an alias in the xml
                  for backwards compatiblity).

                  I am not sure what exactly you mean here , do we have some sample ha-local-tx-datasource/ha-xa-datasource that would deploy in jboss5, yes for backward compatibility .



                  • 6. Re: JBAS-4662 Implementation details.
                    Adrian Brock Master

                     

                    "vickyk" wrote:
                    "adrian@jboss.org" wrote:

                    You do not need seperate metadata for the ha case (it is now just an alias in the xml
                    for backwards compatiblity).

                    I am not sure what exactly you mean here , do we have some sample ha-local-tx-datasource/ha-xa-datasource that would deploy in jboss5, yes for backward compatibility .



                    We don't but users might.

                    ha-xxx-datasource is deprecated, they should just add
                    the parameters to the main datasource config.

                    But we still support the old ha-xxx-datasource using an xml parsing trick to aliias it
                    to the main datasource config.

                    • 7. Re: JBAS-4662 Implementation details.
                      Vicky Kak Master

                      Adrain , while making the changes related to JBAS-4662 in the trunk I noticed that

                      1) The ha behavior in the xa-datasource configuration is not working as expected .
                      I tested the following configuration

                      <xa-datasource>
                      
                       <jndi-name>XAOracleDS1</jndi-name>
                       <reauthentication-mechanism>org.jboss.resource.adapter.jdbc.vendor.DummyReauthenticationMechanism</reauthentication-mechanism>
                       <user-name>scott</user-name>
                       <password>tiger</password>
                       <track-connection-by-tx/>
                       <isSameRM-override-value>false</isSameRM-override-value>
                       <connection-property name="connectionProperties">key=Value</connection-property>
                       <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
                       <xa-datasource-property name="URL">jdbc:oracle:thin:@localhost:1527|jdbc:oracle:thin:@localhost:1523|jdbc:oracle:thin:@localhost:1524|jdbc:oracle:thin:@localhost:1521</xa-datasource-property>
                       <url-delimiter>|</url-delimiter>
                       <url-property>URL</url-property>
                       <!-- xa-datasource-property name="User">scott</xa-datasource-property -->
                       <!-- xa-datasource-property name="Password">tiger</xa-datasource-property -->
                       <!-- xa-datasource-property name="ConnectionProperties">XATransLoose=true</xa-datasource-property -->
                       <min-pool-size>1</min-pool-size>
                       <max-pool-size>5</max-pool-size>
                       <prefill>true</prefill>
                       <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
                       <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
                       <!-- Checks the Oracle error codes and messages for fatal errors -->
                       <!-- exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name -->
                       <!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
                       <no-tx-separate-pools/>
                       <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
                       <metadata>
                       <type-mapping>Oracle9i</type-mapping>
                       </metadata>
                      
                       </xa-datasource>


                      And I get this exception
                      08:04:40,585 INFO [ConnectionFactoryBindingService] Unbound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=XAOracleDS1' from JNDI name 'java:XAOracleDS1'
                      08:04:48,109 WARN [JBossManagedConnectionPool] Unable to fill pool
                      org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (java.sql.SQLException: Io exception: Invalid connection string format, a valid format is: "host:port:sid" )
                       at org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:452)
                       at org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.createManagedConnection(XAManagedConnectionFactory.java:405)
                       at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:611)
                       at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.fillToMin(InternalManagedConnectionPool.java:527)
                       at org.jboss.resource.connectionmanager.PoolFiller.run(PoolFiller.java:74)
                       at java.lang.Thread.run(Thread.java:595)
                      Caused by: java.sql.SQLException: Io exception: Invalid connection string format, a valid format is: "host:port:sid"
                       at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
                       at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
                       at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
                       at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
                       at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:414)
                       at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
                       at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
                       at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
                       at oracle.jdbc.pool.OracleDataSource.getPhysicalConnection(OracleDataSource.java:297)
                       at oracle.jdbc.xa.client.OracleXADataSource.getPooledConnection(OracleXADataSource.java:456)
                       at oracle.jdbc.xa.client.OracleXADataSource.getXAConnection(OracleXADataSource.java:143)
                       at oracle.jdbc.xa.client.OracleXADataSource.getXAConnection(OracleXADataSource.java:129)
                       at org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:444)
                       ... 5 more
                      08:04:49,844 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=XAOracleDS1' to JNDI name 'java:XAOracleDS1'


                      In the above configuration the last URL is valid so it should have been considered but the deployment does not consider the chain of URL's seperated by url delimiter .

                      2) The similar changes in the local-tx-datasource works as expected .

                      I have noticed that this from the logs

                      2008-04-23 08:04:43,856 DEBUG [org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory] (HDScanner) inside the initSelectornull
                      


                      which appears to be coming from
                      private void initSelector() throws JBossResourceException
                       {
                       log.debug("inside the initSelector"+urlProperty);
                       if(urlProperty != null && urlProperty.length() > 0)
                       {
                       String urlsStr = xaProps.getProperty(urlProperty);
                       if(urlsStr != null && urlsStr.trim().length() > 0 && urlDelimiter != null && urlDelimiter.trim().length() > 0)
                       {
                       List xaDataList = new ArrayList();


                      I also confirmed that the JBAS-4662 changes are not causing this issue , will have to see how the Deployment builder populate the values from the MetaData into the MBeanService through the ServiceMetaData .

                      Any thoughts here ?

                      • 8. Re: JBAS-4662 Implementation details.
                        Adrian Brock Master

                        It's a bug in the new deployer. It was constructing but not adding the URLProperty
                        to the MCF properties.

                        Fixed:

                        [ejort@warjort connector]$ svn diff
                        Index: src/main/org/jboss/resource/metadata/mcf/XADataSourceDeploymentMetaData.java
                        ===================================================================
                        --- src/main/org/jboss/resource/metadata/mcf/XADataSourceDeploymentMetaData.java (revision 72614)
                        +++ src/main/org/jboss/resource/metadata/mcf/XADataSourceDeploymentMetaData.java (working copy)
                        @@ -162,6 +162,7 @@
                         property.setName("URLProperty");
                         property.setValue(getURLProperty());
                         }
                        + properties.add(property);
                        
                         return properties;
                         }
                        


                        • 9. Re: JBAS-4662 Implementation details.
                          Vicky Kak Master

                          It passes with this configuration now

                          <datasources>
                          
                           <xa-datasource>
                          
                           <jndi-name>XAOracleDS</jndi-name>
                          
                           <reauthentication-mechanism>org.jboss.resource.adapter.jdbc.vendor.DummyReauthenticationMechanism</reauthentication-mechanism>
                           <user-name>scott</user-name>
                           <password>tiger</password>
                           <track-connection-by-tx/>
                           <isSameRM-override-value>false</isSameRM-override-value>
                           <connection-property name="connectionProperties">key=Value</connection-property>
                           <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
                           <xa-datasource-property name="uRL">jdbc:oracle:thin:@localhost:1522|jdbc:oracle:thin:@localhost:1523|jdbc:oracle:thin:@localhost:1524|jdbc:oracle:thin:@localhost:1521</xa-datasource-property>
                           <!-- connection-url>jdbc:oracle:thin:@localhost:1522|jdbc:oracle:thin:@localhost:1523|jdbc:oracle:thin:@localhost:1524|jdbc:oracle:thin:@localhost:1521</connection-url -->
                          
                           <!-- driver-class>oracle.jdbc.driver.OracleDriver</driver-class -->
                           <url-delimiter>|</url-delimiter>
                           <url-property>uRL</url-property>
                           <!-- xa-datasource-property name="User">scott</xa-datasource-property -->
                           <!-- xa-datasource-property name="Password">tiger</xa-datasource-property -->
                           <!-- xa-datasource-property name="ConnectionProperties">XATransLoose=true</xa-datasource-property -->
                           <min-pool-size>1</min-pool-size>
                           <max-pool-size>5</max-pool-size>
                           <prefill>true</prefill>
                          
                           <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
                           <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
                           <!-- Checks the Oracle error codes and messages for fatal errors -->
                           <!-- exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name -->
                           <!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
                           <no-tx-separate-pools/>
                           <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
                           <metadata>
                           <type-mapping>Oracle9i</type-mapping>
                           </metadata>
                           </xa-datasource>
                          
                           <!-- mbean code="org.jboss.resource.adapter.jdbc.vendor.OracleXAExceptionFormatter"
                           name="jboss.jca:service=OracleXAExceptionFormatter">
                           <depends optional-attribute-name="TransactionManagerService">jboss:service=TransactionManager</depends>
                           </mbean -->
                          
                          </datasources>



                          Here is the results after deployment

                          22:00:25,160 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=XAOracleDS' to JNDI name 'java:XAOracleDS'
                          22:00:30,183 INFO [ConnectionFactoryBindingService] Unbound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=XAOracleDS' from JNDI name 'java:XAOracleDS'
                          22:00:30,262 WARN [XAManagedConnectionFactory] Failed to create an XA connection to jdbc:oracle:thin:@localhost:1522: Could not create connection; - nested throwable: (java.sql.SQLException: Io exception: The Network Adapter could not establish the connection)
                          22:00:30,263 WARN [XAManagedConnectionFactory] Failed to create an XA connection to jdbc:oracle:thin:@localhost:1523: Could not create connection; - nested throwable: (java.sql.SQLException: Io exception: The Network Adapter could not establish the connection)
                          22:00:30,265 WARN [XAManagedConnectionFactory] Failed to create an XA connection to jdbc:oracle:thin:@localhost:1524: Could not create connection; - nested throwable: (java.sql.SQLException: Io exception: The Network Adapter could not establish the connection)
                          22:00:30,281 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=XAOracleDS' to JNDI name 'java:XAOracleDS'


                          This looks perfectly okay as jdbc:oracle:thin:@localhost:1522, jdbc:oracle:thin:@localhost:1523 and jdbc:oracle:thin:@localhost:1524 are invalid URL