glassfish
  1. glassfish
  2. GLASSFISH-20676

com.sun.jts.jtsxa.XID needs to be serializable

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 3.1.2.2
    • Fix Version/s: None
    • Component/s: jts
    • Labels:
      None

      Description

      com.sun.jts.jtsxa.XID implements javax.transaction.xa.Xid which doesn't implement any other interfaces, nor extend anything that can be traced back to java.io.Serializable.

      So at first there doesn't appear to be an absolute requirement for the Xid implementation to be serializable.

      However, the GlassFish XID implementation should be serializable as its a field in the OTSResourceImpl class, which does need to be serializable through a chain of interfaces/extensions:

      com.sun.jts.jtsxa.OTSResourceImpl implements OTSResource
      com.sun.jts.jtsxa.OTSResource implements (amongst other things) org.omg.CORBA.portable.IDLEntity
      org.omg.CORBA.portable.IDLEntity extends Serializable

      Hence if OTSResourceImpl is serialized that will fail because XID is not serializable.

      This appears to have been highlighted in past findbugs reports, for example against GF 2.x: http://www.cs.umd.edu/~pugh/glassfish/glassfish.html

      Class com.sun.jts.jtsxa.OTSResourceImpl defines non-transient non-serializable instance field tranState
      Bug type SE_BAD_FIELD (click for details)
      In class com.sun.jts.jtsxa.OTSResourceImpl
      Field com.sun.jts.jtsxa.OTSResourceImpl.tranState
      In OTSResourceImpl.java

      Class com.sun.jts.jtsxa.OTSResourceImpl defines non-transient non-serializable instance field xaRes
      Bug type SE_BAD_FIELD (click for details)
      In class com.sun.jts.jtsxa.OTSResourceImpl
      Field com.sun.jts.jtsxa.OTSResourceImpl.xaRes
      In OTSResourceImpl.java

      Class com.sun.jts.jtsxa.OTSResourceImpl defines non-transient non-serializable instance field xid
      Bug type SE_BAD_FIELD (click for details)
      In class com.sun.jts.jtsxa.OTSResourceImpl
      Field com.sun.jts.jtsxa.OTSResourceImpl.xid
      In OTSResourceImpl.java

      This has been seen with a combination of Glassfish + Coherence JCA resource adapter using UserTransaction:

      [#|2013-06-27T14:57:50.097+0100|WARNING|glassfish3.1.2|javax.enterprise.system.core.transaction.com.sun.jts.jtsxa|_ThreadID=26;_ThreadName=Thread-2;|JTS5067: Unexpected error occurred in commit

      (Wrapped) java.io.NotSerializableException: com.sun.jts.jtsxa.XID

      at com.tangosol.util.ExternalizableHelper.toBinary(ExternalizableHelper.java:216)

      at com.tangosol.net.partition.DefaultKeyPartitioningStrategy.calculateBasePartition(DefaultKeyPartitioningStrategy.java:90)

      at com.tangosol.net.partition.DefaultKeyPartitioningStrategy.calculateKeyPartition(DefaultKeyPartitioningStrategy.java:72)

      at com.tangosol.net.partition.DefaultKeyPartitioningStrategy.getKeyPartition(DefaultKeyPartitioningStrategy.java:42)

      at com.tangosol.coherence.transaction.internal.storage.StorageKeyPartitioningStrategy.getKeyPartition(StorageKeyPartitioningStrategy.java:33)

      at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.PartitionedService$ConverterKeyToBinary.convert(PartitionedService.CDB:88)

      at com.tangosol.util.ConverterCollections$ConverterMap.remove(ConverterCollections.java:1690)

      at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$ViewMap.remove(PartitionedCache.CDB:1)

      at com.tangosol.coherence.component.util.SafeNamedCache.remove(SafeNamedCache.CDB:1)

      at com.tangosol.coherence.transaction.internal.xa.XAResourceImpl.remove(XAResourceImpl.java:626)

      at com.tangosol.coherence.transaction.internal.xa.XAResourceImpl.commit(XAResourceImpl.java:162)

      at com.sun.jts.jtsxa.OTSResourceImpl.commit_one_phase(OTSResourceImpl.java:174)

      at com.sun.jts.CosTransactions.RegisteredResources.commitOnePhase(RegisteredResources.java:1565)

      at com.sun.jts.CosTransactions.TopCoordinator.commitOnePhase(TopCoordinator.java:2956)

      at com.sun.jts.CosTransactions.CoordinatorTerm.commit(CoordinatorTerm.java:322)

      at com.sun.jts.CosTransactions.TerminatorImpl.commit(TerminatorImpl.java:250)

      at com.sun.jts.CosTransactions.CurrentImpl.commit(CurrentImpl.java:633)

      at com.sun.jts.jta.TransactionManagerImpl.commit(TransactionManagerImpl.java:332)

      at com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate.commitDistributedTransaction(JavaEETransactionManagerJTSDelegate.java:185)

      at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.commit(JavaEETransactionManagerSimplified.java:861)

      at com.sun.enterprise.transaction.UserTransactionImpl.commit(UserTransactionImpl.java:208)

      at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1011)

      at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:755)

      at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:724)

      at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:475)

      at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:270)

      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)

      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)

      at $Proxy214.generateToken(Unknown Source)

        Activity

        Hide
        tecknobabble added a comment -

        Can provide a simple testcase to generate the above error, however don't see any option where I can add an attachment.

        Requires Oracle Coherence for Java 3.7.1, available from: http://www.oracle.com/technetwork/middleware/coherence/downloads/index.html

        A simple servlet which imports:

        import com.tangosol.coherence.transaction.Connection;
        import com.tangosol.coherence.transaction.ConnectionFactory;
        import com.tangosol.coherence.transaction.OptimisticNamedCache;

        which has a service method which calls:

        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        UserTransaction tx = null;

        InitialContext ctx = new InitialContext();
        tx = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
        tx.begin();

        ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:comp/env/eis/CoherenceTxCF");
        Connection con = cf.createConnection("TransactionalCache");
        OptimisticNamedCache cache = con.getNamedCache("tx-cache");
        out.println("PUT: " + cache.put(1, "test") + "<br />");
        out.println("GET: " + cache.get(1) + "<br /");

        tx.commit();

        will generate the "java.io.NotSerializableException: com.sun.jts.jtsxa.XID" error.

        The coherence.jar file needs to be placed in the domain's lib directory.
        The coherence-transaction.rar needs to be deployed and a connector resource created with the jndi name eis/CoherenceTxCF.

        web.xml needs a resource ref for the coherence connection factory:

        <resource-ref>
        <res-ref-name>eis/CoherenceTxCF</res-ref-name>
        <res-type>com.tangosol.coherence.transaction.ConnectionFactory</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
        </resource-ref>

        The glassfish-web.xml requires a resource ref adding:

        <resource-ref>
        <res-ref-name>eis/CoherenceTxCF</res-ref-name>
        <jndi-name>eis/CoherenceTxCF</jndi-name>
        </resource-ref>

        Show
        tecknobabble added a comment - Can provide a simple testcase to generate the above error, however don't see any option where I can add an attachment. Requires Oracle Coherence for Java 3.7.1, available from: http://www.oracle.com/technetwork/middleware/coherence/downloads/index.html A simple servlet which imports: import com.tangosol.coherence.transaction.Connection; import com.tangosol.coherence.transaction.ConnectionFactory; import com.tangosol.coherence.transaction.OptimisticNamedCache; which has a service method which calls: response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); UserTransaction tx = null; InitialContext ctx = new InitialContext(); tx = (UserTransaction) ctx.lookup("java:comp/UserTransaction"); tx.begin(); ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:comp/env/eis/CoherenceTxCF"); Connection con = cf.createConnection("TransactionalCache"); OptimisticNamedCache cache = con.getNamedCache("tx-cache"); out.println("PUT: " + cache.put(1, "test") + "<br />"); out.println("GET: " + cache.get(1) + "<br /"); tx.commit(); will generate the "java.io.NotSerializableException: com.sun.jts.jtsxa.XID" error. The coherence.jar file needs to be placed in the domain's lib directory. The coherence-transaction.rar needs to be deployed and a connector resource created with the jndi name eis/CoherenceTxCF. web.xml needs a resource ref for the coherence connection factory: <resource-ref> <res-ref-name>eis/CoherenceTxCF</res-ref-name> <res-type>com.tangosol.coherence.transaction.ConnectionFactory</res-type> <res-auth>Container</res-auth> <res-sharing-scope>Shareable</res-sharing-scope> </resource-ref> The glassfish-web.xml requires a resource ref adding: <resource-ref> <res-ref-name>eis/CoherenceTxCF</res-ref-name> <jndi-name>eis/CoherenceTxCF</jndi-name> </resource-ref>

          People

          • Assignee:
            marina vatkina
            Reporter:
            tecknobabble
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: