1 Reply Latest reply on Jun 6, 2006 3:34 PM by weston.price

    please help me for the error of

    yuanwh

      Hi, I use JTA to control transaction with Oracle 9i and JBoss 4.02. but each time I call commit(), it always throw the exception of "The XID is not valid"
      I have tried it both by ojdbc14.jar && classes12.jar. Any one can give me some tips? thank in advance!

      my oracle-xa-ds.xml is like this:

      <datasources>
       <xa-datasource>
       <jndi-name>XAOracleDS1</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>
       <xa-datasource-property name="URL">jdbc:oracle:thin:@host1:1521:orcl</xa-datasource-property>
       <xa-datasource-property name="User">a</xa-datasource-property>
       <xa-datasource-property name="Password">r</xa-datasource-property>
       <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
       <no-tx-separate-pools/>
       <metadata>
       <type-mapping>Oracle9i</type-mapping>
       </metadata>
       </xa-datasource>
       <xa-datasource>
       <jndi-name>XAOracleDS</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>
       <xa-datasource-property name="URL">jdbc:oracle:thin:@host2:1521:orcl</xa-datasource-property>
       <xa-datasource-property name="User">tt</xa-datasource-property>
       <xa-datasource-property name="b">nt</xa-datasource-property>
       <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
       <no-tx-separate-pools/>
       <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>


      and my demo code is like this:
      UserTransaction utx = (UserTransaction)ctx.lookup("java:/comp/UserTransaction");
      
      utx.begin();
      DataSource ds = (DataSource)ctx.lookup("java:/XAOracleDS");
      Connection conn = ds.getConnection();
      DataSource ds1 = (DataSource)ctx.lookup("java:/XAOracleDS1");
      Connection conn1 = ds1.getConnection();
      PreparedStatement stmt = conn.prepareStatement("insert into test2 values(98, 'ee', 'bbb')");
      PreparedStatement stmt1 = conn1.prepareStatement("insert into p_ax values('qwe', 567, 'fff')");
      
      try {
       stmt.executeUpdate();
       stmt1.executeUpdate();
       utx.commit();
      } catch (Exception e) {
       utx.rollback();
       throw e;
      } finally {
      stmt.close();
      conn.close();
      stmt1.close();
      conn1.close();


        • 1. Re: please help me for the error of
          weston.price

          Did you specify to pad the XID in the Transaction Service? This is clearly outlined in the Wiki.

          Please see your jboss-service.xml file and look for


          <!--attribute name="Pad">true</attribute-->


          The 'Pad' attribute should be uncommented for Oracle XA deployments.