Index: connector/src/main/org/jboss/resource/adapter/jdbc/xa/XAManagedConnection.java
===================================================================
RCS file: /cvsroot/jboss/jbosscx/src/main/org/jboss/resource/adapter/jdbc/xa/XAManagedConnection.java,v
retrieving revision 1.2
diff -u -r1.2 XAManagedConnection.java
--- connector/src/main/org/jboss/resource/adapter/jdbc/xa/XAManagedConnection.java	1 Dec 2001 18:08:18 -0000	1.2
+++ connector/src/main/org/jboss/resource/adapter/jdbc/xa/XAManagedConnection.java	14 Jun 2002 20:35:44 -0000
@@ -30,6 +30,7 @@
 {
    private XAConnection con;
    private XADataSource source;
+   private XAResource res;
    private int transactionIsolation;
 
    /*
@@ -70,12 +71,21 @@
     * @return                                      The XAResource value
     * @exception javax.resource.ResourceException  Description of Exception
     */
-   public XAResource getXAResource()
-          throws javax.resource.ResourceException
+   public synchronized XAResource getXAResource()
+          // ifedorenko remove synchronized if it does not make sense here
+       throws javax.resource.ResourceException
    {
       try
       {
-         return con.getXAResource();
+         // ifedorenko
+         // Cache XAResource as a workaround for a bug in oracle xa driver
+         // which returns a different XAResource for each getXAResource call
+         // (see JDBC 2.0 spec, section 7.2.2 for a reason why it should not).
+         if (res == null)
+         {
+            res = con.getXAResource();
+         }
+         return res;
       }
       catch (SQLException e)
       {
Index: server/src/main/org/jboss/tm/XidImpl.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/tm/Attic/XidImpl.java,v
retrieving revision 1.14
diff -u -r1.14 XidImpl.java
--- server/src/main/org/jboss/tm/XidImpl.java	12 Dec 2001 22:12:18 -0000	1.14
+++ server/src/main/org/jboss/tm/XidImpl.java	14 Jun 2002 20:35:52 -0000
@@ -144,7 +144,15 @@
     */
    public byte[] getGlobalTransactionId()
    {
-      return (byte[])globalId.clone();
+      // ifedorenko
+      // Oracle xa driver throws XAException.XAER_NOTA (The XID is not valid)
+      // if returned value does not have some padding zeros.
+      // I do not know what the limitation is but their examples seem to
+      // always use 64 byte arrays. I checked that JBossMQ accepts such
+      // ids but do not know if other resource managers do.
+      byte[] result = new byte[Xid.MAXGTRIDSIZE];
+      System.arraycopy(globalId, 0, result, 0, globalId.length);
+      return result;
    }
 
    /**
@@ -152,10 +160,10 @@
     */
    public byte[] getBranchQualifier()
    {
-      if (branchId.length == 0)
-         return branchId; // Zero length arrays are immutable.
-      else
-         return (byte[])branchId.clone();
+      // ifedorenko see my comments above
+      byte[] result = new byte[Xid.MAXBQUALSIZE];
+      System.arraycopy(branchId, 0, result, 0, branchId.length);
+      return result;
    }
 
    /**
