3 Replies Latest reply on Sep 6, 2005 9:57 AM by jaikiran

    JMSExpection: Invalid transaction id.

    bnadesan

      Hi All,

      I'm tring to use JMS and When I send a message to the Queue. I get the following exception. I'm currently using JBoss 3.2.3. I hope someone can help me in resolving this issue.

      javax.jms.JMSException: Invalid transaction id.
      at org.jboss.mq.SpyXAResourceManager.addMessage(SpyXAResourceManager.java:95)
      at org.jboss.mq.SpySession.sendMessage(SpySession.java:728)
      at org.jboss.mq.SpyQueueSender.internalSend(SpyQueueSender.java:118)
      at org.jboss.mq.SpyQueueSender.send(SpyQueueSender.java:68)
      at movie.ejb.MessageControllerBean.sendMessage(Unknown Source)
      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.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:297)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
      at org.jboss.ejb.Container.invoke(Container.java:700)
      at sun.reflect.GeneratedMethodAccessor40.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:101)
      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:90)
      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)
      at org.jboss.proxy.ejb.StatefulSessionInterceptor.invoke(StatefulSessionInterceptor.java:104)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
      at $Proxy46.sendMessage(Unknown Source)
      at movie.ejb.ReservationBean.bookSeats(Unknown Source)
      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.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:297)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
      at org.jboss.ejb.Container.invoke(Container.java:700)
      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.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:101)
      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:90)
      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)
      at org.jboss.proxy.ejb.StatefulSessionInterceptor.invoke(StatefulSessionInterceptor.java:104)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
      at $Proxy48.bookSeats(Unknown Source)

        • 1. Re: JMSExpection: Invalid transaction id.
          jaikiran

          Please post the code in which you are sending the message

          • 2. Re: JMSExpection: Invalid transaction id.
            bnadesan

            Here is the code snippet

            package movie.ejb;

            import java.rmi.*;
            import javax.ejb.*;
            import javax.jms.*;
            import javax.naming.*;

            /**
            * @ejb.bean
            * name="MessageController"
            * extends="javax.ejb.MovieSessionBean"
            * view-type="remote"
            * jndi-name="movie.ejb.MessageControllerHome"
            * description="EJB to handle Message Notification"
            *
            * @ejb.interface
            * remote-class="movie.ejb.MessageController"
            * extends="javax.ejb.EJBObject"
            * @ejb.home
            * remote-class="movie.ejb.MessageControllerHome"
            * extends="javax.ejb.EJBHome"
            *
            *
            * @ejb.transaction
            * type="Supports"
            * @ejb.util generate = "physical"
            *
            * @ejb.resource-ref res-ref-name = "jms/QueueConnectionFactory"
            * res-type = "javax.jms.QueueConnectionFactory"
            * res-auth = "Container"
            * @jboss.resource-ref res-ref-name = "jms/QueueConnectionFactory"
            * jndi-name = "java:/JmsXA"
            *
            */

            public class MessageControllerBean extends MovieSessionBean{

            private QueueSession qsession;
            private QueueSender qsender;
            private Queue queue;

            /**
            * @ejb.create-method
            */
            public void ejbCreate() throws RemoteException {
            try {
            String JMS_FACTORY="java:comp/env/jms/QueueConnectionFactory";
            String QUEUE="queue/testQueue";
            Context namingCtx = new InitialContext();
            QueueConnectionFactory qconFactory =
            (QueueConnectionFactory) namingCtx.lookup(JMS_FACTORY);

            QueueConnection qcon = qconFactory.createQueueConnection();
            qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
            queue = (Queue) namingCtx.lookup(QUEUE);
            } catch (Exception e) {
            e.printStackTrace();
            throw new RemoteException(e.getMessage());
            }
            }

            /**
            * Send message method.
            *
            * @ejb.interface-method
            */
            public void sendMessage(String message) throws RemoteException {
            try {
            TextMessage msg = qsession.createTextMessage();
            msg.setText(message);
            qsender = qsession.createSender(queue);
            qsender.send(msg);
            } catch (Exception e) {
            e.printStackTrace();
            throw new RemoteException(e.getMessage());
            }
            }
            }

            • 3. Re: JMSExpection: Invalid transaction id.
              jaikiran

              Instead of the following, use "Required" as the transaction type

              @ejb.transaction
              * type="Supports"


              Instead, use:

              @ejb.transaction
              * type="Required"


              I think this might work. Try it out