5 Replies Latest reply on Aug 4, 2003 1:20 PM by adrian.brock

    JMSException: Invalid transaction id

    morgan

      Hi,

      I have an MDB that receives a message, does some stuff, and then
      sends out a message. It's receiving the message fine, but when it
      goes to send the new message an "Invalid transaction id" JMSException
      is generated -- the stack trace is at the end of this message. I
      searched the JBoss forums and didn't come across anything that helped,
      and then I searched the "jboss-user" mailing list on SourceForge.
      There I came across the thread Problem with MDB and CMT in
      JBoss3.2RC2 (SSB and CMT works fine)
      . Igor Fedorenko suggested
      adding "@ejb:transaction type=Required" to the MDB's class comments
      as a quick fix (I'm also using XDoclet). Well, this worked for me
      (using jboss-3.2.2RC1_tomcat-4.1.24). Igor said that JBoss could
      not match "transaction=Required" metadata specified for the "onMessage"
      method. Being a novice I'm not 100% sure what's going on ... Does
      his solution seem reasonable? Is this indictative of a problem
      that still exists in JBoss (his post was from February 2003) and
      should/will be fixed? Anyway, I'm just curious and trying to learn.

      Thanks,

      Paul

      [pre]javax.jms.JMSException: Invalid transaction id.
      at org.jboss.mq.SpyXAResourceManager.addMessage(SpyXAResourceManager.java:95)
      at org.jboss.mq.SpySession.sendMessage(SpySession.java:695)
      at org.jboss.mq.SpyQueueSender.internalSend(SpyQueueSender.java:118)
      at org.jboss.mq.SpyQueueSender.send(SpyQueueSender.java:68)
      at com.mv.worddance.ejb.WDBNotifierBean.notifyRecipient(WDBNotifierBean.java:255)
      at com.mv.worddance.ejb.WDBNotifierBean.onMessage(WDBNotifierBean.java:164)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.java:434)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
      at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstanceInterceptor.java:62)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:216)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:104)
      at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:90)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:348)
      at org.jboss.ejb.Container.invoke(Container.java:673)
      at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.java:758)
      at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(JMSContainerInvoker.java:1046)
      at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:256)
      at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:636)
      at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:442)
      at org.jboss.mq.SpySession.run(SpySession.java:294)
      at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:180)
      at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:727)
      at java.lang.Thread.run(Thread.java:536)[/pre]

        • 1. Re: JMSException: Invalid transaction id

          Are you using java:/JmsXA?

          This should be fixed for 3.2.2RC2,
          (commit from suspended could cause a double removal of
          the transaction id from the session).
          You can also workaround it using
          <track-connection-by-tx>true</track-connection-by-tx>
          in jms-ds.xml for the jms adaptor.

          Regards,
          Adrian

          • 2. Re: JMSException: Invalid transaction id
            morgan

            Sorry, I did intend to include that I'm using "java:/JmsXA". And thanks for the quick response! I *do* appreciate it.

            Paul

            • 3. Re: JMSException: Invalid transaction id
              akirdat

              Adrian,

              I am receiving a similar message, and I did try and add the line you suggested to my jms-ds.xml file, but no luck.

              Here is my stack trace:

              javax.jms.JMSException: Invalid transaction id.
              at org.jboss.mq.SpyXAResourceManager.addMessage(SpyXAResourceManager.java:95)
              at org.jboss.mq.SpySession.sendMessage(SpySession.java:695)
              at org.jboss.mq.SpyQueueSender.internalSend(SpyQueueSender.java:118)
              at org.jboss.mq.SpyQueueSender.send(SpyQueueSender.java:76)

              Also this is what my jms-ds.xml file looks like:

              <connection-factories>
              <!-- ==================================================================== -->
              <!-- JMS Stuff -->
              <!-- ==================================================================== -->

              <!-- The JMS provider loader -->

              DefaultJMSProvider

              org.jboss.jms.jndi.JBossMQProvider

              java:/XAConnectionFactory
              java:/XAConnectionFactory


              <!-- The server session pool for Message Driven Beans -->

              <depends optional-attribute-name="XidFactory">jboss:service=XidFactory
              StdJMSPool

              org.jboss.jms.asf.StdServerSessionPoolFactory



              <!-- JMS XA Resource adapter, use this to get transacted JMS in beans -->

              <tx-connection-factory>

              <jndi-name>JmsXA</jndi-name>

              <xa-transaction/>
              <!-- JBossMQ requires sessions tracked by transaction. Commit from suspended is not supported -->
              <track-connection-by-tx/>

              <adapter-display-name>JMS Adapter</adapter-display-name>

              <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Topic</config-property>

              <security-domain>JmsXARealm</security-domain>

              </tx-connection-factory>

              <tx-connection-factory>

              <jndi-name>MyJMSConnectionFactory</jndi-name>
              <xa-transaction/>

              <!-- JBossMQ requires sessions tracked by transaction. Commit from suspended is not supported -->
              <track-connection-by-tx>true</track-connection-by-tx>

              <adapter-display-name>JMS Adapter</adapter-display-name>

              <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Queue</config-property>
              </tx-connection-factory>
              </connection-factories>


              I am using jboss-3.2.0_tomcat-4.1.24.

              Any help/comments appreciated.

              • 4. Re: JMSException: Invalid transaction id
                akirdat

                This is my client code:

                InitialContext context = new InitialContext();
                Object t_Object = context.lookup(JNDINames.MY_JMS_FACTORY);
                QueueConnectionFactory t_QueueConnectionFactory =
                (QueueConnectionFactory) t_Object;

                //QueueConnection t_queueConnection = JNDILookup.getQueueConnection();
                QueueConnection t_queueConnection =
                t_QueueConnectionFactory.createQueueConnection();


                t_queueSession = t_queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

                Queue t_queue = JNDILookup.getQueue(JNDINames.CASE_HISTORY_QUEUE);

                QueueSender t_queueSender = t_queueSession.createSender(t_queue);


                ObjectMessage t_objectMessage = t_queueSession.createObjectMessage();

                //psuedo myObject variable
                t_objectMessage.setObject(myObject);

                //t_queueSender.send(t_objectMessage, javax.jms.DeliveryMode.NON_PERSISTENT, javax.jms.Message.DEFAULT_PRIORITY, 1800000);
                t_queueSender.send(t_objectMessage);

                Am I doing something wrong here ???

                • 5. Re: JMSException: Invalid transaction id

                  Try using the latest 3.2.2RC2 release to see whether
                  it fixes your problem.

                  The need for <track-connection-by-tx> is gone.
                  The JMS resource adaptor configuration
                  and JBossMQ XASession can now cope with
                  commit from suspended.

                  Regards,
                  Adrian