Jackrabbit Content Repository
  1. Jackrabbit Content Repository
  2. JCR-1333

jackrabbit-jcr-rmi: Supplied javax.transaction.xa.Xid is assumed serializable, but is not on some environments.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.4
    • Fix Version/s: 1.5
    • Component/s: jackrabbit-jcr-rmi
    • Labels:
      None
    • Environment:
      Linux (suse9) with websphere 6.1 invoking jackrabbit client RMI

      Description

      Websphere provides a non-serializable javax.transaction.xa.Xid implementation, causing ClientXAResource to fail with NotSerializableException when passing Xid over RMI.
      I have worked around this by converting the supplied Xid to a local serializable Xid implementation that takes the supplied Xid parameters, and implements hashCode() and equals() correctly:

      private static class SerializableXID implements javax.transaction.xa.Xid, Serializable {
      /**

      • Serial version ID
        */
        private static final long serialVersionUID = -1390620315181450507L;

      private final byte[] branchQualifier;
      private final byte[] globalTransactionId;
      private final int formatId;
      private final int hashCode;

      public SerializableXID(Xid xid)

      { branchQualifier = xid.getBranchQualifier(); globalTransactionId = xid.getGlobalTransactionId(); formatId = xid.getFormatId(); hashCode = xid.hashCode(); }

      public byte[] getBranchQualifier()

      { return branchQualifier; }

      public int getFormatId()

      { return formatId; }

      public byte[] getGlobalTransactionId()

      { return globalTransactionId; }

      public final int hashCode()

      { return hashCode; }

      public final boolean equals(Object obj) {
      if(obj == this)

      { return true; }

      if(!(obj instanceof Xid))

      { return false; }

      Xid xidimpl = (Xid)obj;
      if(formatId != xidimpl.getFormatId())

      { return false; }

      else

      { return Arrays.equals(branchQualifier, xidimpl.getBranchQualifier()) && Arrays.equals(globalTransactionId, xidimpl.getGlobalTransactionId()); }

      }
      }

        Activity

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        26d 1h 33m 1 Jukka Zitting 16/Feb/08 13:20
        Resolved Resolved Closed Closed
        295d 21h 47m 1 Jukka Zitting 08/Dec/08 11:08
        Jukka Zitting made changes -
        Workflow jira [ 12421668 ] no-reopen-closed, patch-avail [ 12468372 ]
        Jukka Zitting made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Jukka Zitting made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        Jukka Zitting added a comment -

        Added the SerializableXid class and related XAResource changes in revision 628289.

        I just hope there are no resource managers that expect to be able to cast the Xid objects to some implementation-specific classes...

        Show
        Jukka Zitting added a comment - Added the SerializableXid class and related XAResource changes in revision 628289. I just hope there are no resource managers that expect to be able to cast the Xid objects to some implementation-specific classes...
        Jukka Zitting made changes -
        Field Original Value New Value
        Component/s jackrabbit-jcr-rmi [ 12310820 ]
        Fix Version/s 1.5 [ 12312920 ]
        Assignee Jukka Zitting [ jukkaz ]
        Paul Gribben created issue -

          People

          • Assignee:
            Jukka Zitting
            Reporter:
            Paul Gribben
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development