4 Replies Latest reply on Mar 15, 2007 7:06 AM by Weston M. Price

    Hibernate+JBossTS+SybaseXA=XAException

    mskonda Apprentice

      Env: JBossTS4.2 and JBM1.2.0GA on JBoss4.0.5GA.

      I have created a simple test using MDB which publishes to a JMS Destination and persists the entity into a table.

      I am using XA Connection Factories and XA Datasoruce for this purpose respectively.

      However, when the transaction is about to commit, I get this exception:

      2007-03-15 10:11:02,140 ERROR [org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory] End transaction failed for XAResource
      javax.transaction.xa.XAException
       at com.sybase.jdbc3.jdbc.SybXAResource.verifyReturnCode(SybXAResource.java:850)
       at com.sybase.jdbc3.jdbc.SybXAResource.sendRPC(SybXAResource.java:763)
       at com.sybase.jdbc3.jdbc.SybXAResource.sendRPC(SybXAResource.java:635)
       at com.sybase.jdbc3.jdbc.SybXAResource.end(SybXAResource.java:369)
       at org.jboss.resource.adapter.jdbc.xa.XAManagedConnection.end(XAManagedConnection.java:147)
       at com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord.topLevelPrepare(XAResourceRecord.java:259)
       at com.arjuna.ats.arjuna.coordinator.BasicAction.doPrepare(BasicAction.java:2872)
       at com.arjuna.ats.arjuna.coordinator.BasicAction.doPrepare(BasicAction.java:2829)
       at com.arjuna.ats.arjuna.coordinator.BasicAction.prepare(BasicAction.java:2383)
       at com.arjuna.ats.arjuna.coordinator.BasicAction.End(BasicAction.java:1784)
       at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:87)
       at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
       at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1181)
       at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:134)
       at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)
       at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:351)
       at org.jboss.jms.client.remoting.MessageCallbackHandler.callOnMessage(MessageCallbackHandler.java:153)
       at org.jboss.jms.client.container.SessionAspect.handleRun(SessionAspect.java:791)
       at org.jboss.aop.advice.org.jboss.jms.client.container.SessionAspect14.invoke(SessionAspect14.java)
       at org.jboss.jms.client.delegate.ClientSessionDelegate$run_N8003352271541955702.invokeNext(ClientSessionDelegate$run_N8003352271541955702.java)
       at org.jboss.jms.client.container.ClosedInterceptor.invoke(ClosedInterceptor.java:171)
       at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:117)
       at org.jboss.jms.client.delegate.ClientSessionDelegate$run_N8003352271541955702.invokeNext(ClientSessionDelegate$run_N8003352271541955702.java)
       at org.jboss.jms.client.container.ExceptionInterceptor.invoke(ExceptionInterceptor.java:71)
       at org.jboss.jms.client.delegate.ClientSessionDelegate$run_N8003352271541955702.invokeNext(ClientSessionDelegate$run_N8003352271541955702.java)
       at org.jboss.jms.client.container.ClientLogInterceptor.invoke(ClientLogInterceptor.java:107)
       at org.jboss.jms.client.delegate.ClientSessionDelegate$run_N8003352271541955702.invokeNext(ClientSessionDelegate$run_N8003352271541955702.java)
       at org.jboss.jms.client.delegate.ClientSessionDelegate.run(ClientSessionDelegate.java)
       at org.jboss.jms.client.JBossSession.run(JBossSession.java:211)
       at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:194)
       at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:743)
       at java.lang.Thread.run(Thread.java:595)
      2007-03-15 10:11:02,142 WARN [org.jboss.resource.connectionmanager.TxConnectionManager] Connection error occured: org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener@6c317dc9[state=NORMAL mc=org.jboss.resource.adapter.jdbc.xa.XAManagedConnection@f0541d handles=0 lastUse=1173953462136 permit=false trackByTx=false mcp=org.jboss.resource.connectionmanager.JBossManagedConnectionPool$OnePool@7aa8be43 context=org.jboss.resource.connectionmanager.InternalManagedConnectionPool@5c635f9e xaResource=org.jboss.resource.adapter.jdbc.xa.XAManagedConnection@f0541d txSync=null]
      javax.transaction.xa.XAException
       at com.sybase.jdbc3.jdbc.SybXAResource.verifyReturnCode(SybXAResource.java:850)
       at com.sybase.jdbc3.jdbc.SybXAResource.sendRPC(SybXAResource.java:763)
       at com.sybase.jdbc3.jdbc.SybXAResource.sendRPC(SybXAResource.java:635)
       at com.sybase.jdbc3.jdbc.SybXAResource.end(SybXAResource.java:369)
       at org.jboss.resource.adapter.jdbc.xa.XAManagedConnection.end(XAManagedConnection.java:147)
       at com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord.topLevelPrepare(XAResourceRecord.java:259)
       at com.arjuna.ats.arjuna.coordinator.BasicAction.doPrepare(BasicAction.java:2872)
       at com.arjuna.ats.arjuna.coordinator.BasicAction.doPrepare(BasicAction.java:2829)
       at com.arjuna.ats.arjuna.coordinator.BasicAction.prepare(BasicAction.java:2383)
       at com.arjuna.ats.arjuna.coordinator.BasicAction.End(BasicAction.java:1784)
       at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:87)
       at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
       at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1181)
       at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:134)
       at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)
       at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:351)
       at org.jboss.jms.client.remoting.MessageCallbackHandler.callOnMessage(MessageCallbackHandler.java:153)
       at org.jboss.jms.client.container.SessionAspect.handleRun(SessionAspect.java:791)
       at org.jboss.aop.advice.org.jboss.jms.client.container.SessionAspect14.invoke(SessionAspect14.java)
       at org.jboss.jms.client.delegate.ClientSessionDelegate$run_N8003352271541955702.invokeNext(ClientSessionDelegate$run_N8003352271541955702.java)
       at org.jboss.jms.client.container.ClosedInterceptor.invoke(ClosedInterceptor.java:171)
       at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:117)
       at org.jboss.jms.client.delegate.ClientSessionDelegate$run_N8003352271541955702.invokeNext(ClientSessionDelegate$run_N8003352271541955702.java)
       at org.jboss.jms.client.container.ExceptionInterceptor.invoke(ExceptionInterceptor.java:71)
       at org.jboss.jms.client.delegate.ClientSessionDelegate$run_N8003352271541955702.invokeNext(ClientSessionDelegate$run_N8003352271541955702.java)
       at org.jboss.jms.client.container.ClientLogInterceptor.invoke(ClientLogInterceptor.java:107)
       at org.jboss.jms.client.delegate.ClientSessionDelegate$run_N8003352271541955702.invokeNext(ClientSessionDelegate$run_N8003352271541955702.java)
       at org.jboss.jms.client.delegate.ClientSessionDelegate.run(ClientSessionDelegate.java)
       at org.jboss.jms.client.JBossSession.run(JBossSession.java:211)
       at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:194)
       at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:743)
       at java.lang.Thread.run(Thread.java:595)
      2007-03-15 10:11:02,148 WARN [com.arjuna.ats.jta.logging.loggerI18N] [com.arjuna.ats.internal.jta.resources.arjunacore.preparefailed] [com.arjuna.ats.internal.jta.resources.arjunacore.preparefailed] XAResourceRecord.prepare - prepare failed with exception XAException.XAER_PROTO
      2007-03-15 10:11:02,149 WARN [com.arjuna.ats.arjuna.logging.arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.BasicAction_36] - BasicAction.End() - prepare phase of action-id a6edd5e:908d:45f91b89:92 failed.
      2007-03-15 10:11:02,149 WARN [com.arjuna.ats.arjuna.logging.arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.BasicAction_38] - Action Aborting
      2007-03-15 10:11:02,151 ERROR [org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory] End transaction failed for XAResource
      

      This is MDB code:
       public void onMessage(Message message)
       {
       ....
       if(!message.getJMSRedelivered())
       {
       publishXA("/topic/testTopic3");
       persitCat();
       logger.info("Message Delivered Successfully in publish");
       }
      }
      
      public void publishXA(String destinationName) throws Exception
       {
      
       logger.info("Only one message");
       Connection conn = null;
      
       try
       {
      
       ConnectionFactory fac = (ConnectionFactory)mdbContext.lookup("java:/JmsXA");
      
       logger.info("-->got xa conn fact"+fac);
      
       conn = fac.createConnection();
      
       logger.info("-->created conns");
      
       Session xaSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      
       logger.info("-->created sessions");
      
       Topic topic = (Topic) getContext().lookup(destinationName);
      
       logger.info("Topic " + destinationName + " exists");
      
       MessageProducer publisher = xaSession.createProducer(topic);
      
       logger.info("-->created pubishers");
      
       TextMessage message = xaSession.createTextMessage("Hello! I'm XA Message");
      
       logger.info("-->created txtmsgs");
      
       publisher.send(message);
      
      // publishNonXA(destinationName);
      
       }catch(Exception e)
       {
       logger.info("Exception in onMessage() "+e.getMessage());
       e.printStackTrace();
       }
       finally
       {
       closeConnection(conn);
       }
       }
       public void persitCat() throws Exception
       {
       SessionFactory sessionFactory = (SessionFactory) getContext().lookup(HIBERNATE_SF_JNDI_NAME);
      
       logger.info("SessionFactory found: "+sessionFactory);
      
       org.hibernate.Session session = (org.hibernate.Session) sessionFactory.getCurrentSession();
      
       logger.info("Session created: "+session);
      
       HibernateCat cat = new HibernateCat();
      
       cat.setId(System.currentTimeMillis());
      
       cat.setFname("Larry");
       cat.setLname("Barry");
      
       logger.info("Logging HibernateCat");
       session.save(cat);
       logger.info("HibernateCat saved!!");
       }
      

      Pardon me if this has nothing to do with JBossTS.

      Thanks
      Madhu