1 Reply Latest reply on Feb 22, 2010 9:21 AM by fredk

    How to create a XA aware connection factory

    fredk

      Hi,

       

      Currently I have a connection factory that supports local transactions, but since I need to connect to another database I have to transform it to a XA aware factory.

       

      I changed my resource adapter configuration to support XATransactions, changed my custom factory class to extend org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory

      and my changed my xa-ds.xml as attached.

       

      After deploying the code on JBoss 5.1.0.GA

      This is the error message:

      16:43:51 WARN  [main] JBossManagedConnectionPool.warn(363) Throwable while attempting to get a new connection: null
      org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (java.sql.SQLException: Ongeldige Oracle-URL opgegeven.: OracleDataSource.makeURL)
              at org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:465)
              at org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.createManagedConnection(XAManagedConnectionFactory.java:409)
              at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:633)
              at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:267)
              at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:679)
              at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:404)
              at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:381)
              at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:496)
              at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:941)
              at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89)
              at nl.xa.OracleWrapperDataSource.getConnection(OracleWrapperDataSource.java:45)

      ...

      ...

       

      (BTW translation 'Ongeldige Oracle-URL opgegeven' is about the same as 'Passed invalid Oracle-URL')

       

      I tried to change 'ConnectionURL' to 'URL' and to 'URLProperty' but those won't work either. What am I doing wrong.

        • 1. Re: How to create a XA aware connection factory
          fredk

          After spitting through the jboss sourcecode I solved the problem myself:

           

          the property 'URLProperty' refers to a named property in the config-property XADataSourceProperties

           

          So one should use the following lines in the connection factory:

          <config-property name="URLProperty" type="java.lang.String">$PROPNAME</config-property>

          <config-property name="XADataSourceProperties" type="java.lang.String">$PROPNAME=$CONNECTIONSTRING</config-property>

           

          where the both $PROPNAME's should be the same and the $CONNECTIONSTRING should be the connection string

           

          e.g.

           

          <config-property name="URLProperty" type="java.lang.String">URL</config-property>

          <config-property name="XADataSourceProperties" type="java.lang.String">URL=jdbc:thin:@localhost:1521:XE</config-property>