Invalid transaction id.
svaughan Feb 10, 2004 5:05 PMHello, after following what I can find in both the commercial docs and Google and other posts in these forums, I am still stopped dead by a JMSException: Invalid transaction id. I have an MDB that wants to transactionally send a message to a Queue (another MDB). Essentially what appears to be happening is that a new SpySession is being created (which looks wrong) without the Xid of the original MDB's transaction (which is even further astray). The SpyXAResourceManager's addMessage(Object xid, SpyMessage msg) is always passed Null for the xid parameter because either the SpySession is new (possibly wrong to begin with, I don't understand why the original SpySession is not pulled from the ENC context) or because the new SpySession's setCurrentTransactionId(Object xid) is never called. Anyway, here is the relevant log (with TRACE set full on for org.jboss.mq packages):
2004-02-10 16:22:33,884 DEBUG [org.jboss.jms.jndi.JBossMQProvider] no provider url; connecting to local JNDI
2004-02-10 16:22:33,884 DEBUG [org.jboss.jms.jndi.JBossMQProvider] created context: javax.naming.InitialContext@f30093
2004-02-10 16:22:33,884 DEBUG [org.jboss.jms.ConnectionFactoryHelper] using connection factory: org.jboss.mq.SpyXAConnectionFactory@161c9d1
2004-02-10 16:22:33,884 DEBUG [org.jboss.jms.ConnectionFactoryHelper] using username/password: guest/guest
2004-02-10 16:22:33,884 TRACE [org.jboss.mq.Connection] Connection Initializing
2004-02-10 16:22:33,884 TRACE [org.jboss.mq.Connection] Getting the serverIL
2004-02-10 16:22:33,884 TRACE [org.jboss.mq.Connection] serverIL=org.jboss.mq.il.jvm.JVMServerIL@183d59c
2004-02-10 16:22:33,884 TRACE [org.jboss.mq.Connection] Authenticating
2004-02-10 16:22:33,884 TRACE [org.jboss.mq.Connection] Authenticating user guest
2004-02-10 16:22:33,894 TRACE [org.jboss.mq.server.TracingInterceptor] CALLED : authenticate
2004-02-10 16:22:33,894 TRACE [org.jboss.mq.security.ServerSecurityInterceptor] Autenticating user guest/guest
2004-02-10 16:22:33,894 TRACE [org.jboss.mq.security.SecurityManager] Username: guest is authenticated
2004-02-10 16:22:33,894 TRACE [org.jboss.mq.security.SecurityManager] Adding group : class org.jboss.security.NestableGroup Roles(members:guest)
2004-02-10 16:22:33,894 TRACE [org.jboss.mq.server.TracingInterceptor] RETURN : authenticate
2004-02-10 16:22:33,894 TRACE [org.jboss.mq.server.TracingInterceptor] CALLED : checkUser
2004-02-10 16:22:33,894 TRACE [org.jboss.mq.server.TracingInterceptor] ARG : guest
2004-02-10 16:22:33,894 TRACE [org.jboss.mq.server.TracingInterceptor] ARG : (password not shown)
2004-02-10 16:22:33,894 TRACE [org.jboss.mq.server.TracingInterceptor] RETURN : checkUser
2004-02-10 16:22:33,894 TRACE [org.jboss.mq.Connection] Starting the clientIL service
2004-02-10 16:22:33,894 DEBUG [org.jboss.mq.GenericConnectionFactory] Handing out ClientIL: org.jboss.mq.il.jvm.JVMClientILService
2004-02-10 16:22:33,894 TRACE [org.jboss.mq.Connection] Connection establishment successful
2004-02-10 16:22:33,894 DEBUG [org.jboss.jms.ConnectionFactoryHelper] created XAQueueConnection: org.jboss.mq.SpyXAConnection@1aabda3
2004-02-10 16:22:33,894 DEBUG [org.jboss.resource.adapter.jms.JmsManagedConnection] created connection: org.jboss.mq.SpyXAConnection@1aabda3
2004-02-10 16:22:33,894 TRACE [org.jboss.mq.Connection] Checking clientID :null
2004-02-10 16:22:33,894 TRACE [org.jboss.mq.server.TracingInterceptor] CALLED : getID
2004-02-10 16:22:33,894 TRACE [org.jboss.mq.server.TracingInterceptor] RETURN : getID
2004-02-10 16:22:33,894 TRACE [org.jboss.mq.Connection] Connection establishment successful
2004-02-10 16:22:33,894 TRACE [org.jboss.mq.SpySession] Connection: org.jboss.mq.SpyXAConnection@1aabda3, transacted:true, ack:0, xaSession: true
2004-02-10 16:22:33,894 DEBUG [org.jboss.resource.adapter.jms.JmsManagedConnection] xaQueueSession=org.jboss.mq.SpyQueueSession@88485f, queueSession=org.jboss.mq.SpyQueueSession@88485f
2004-02-10 16:22:33,894 TRACE [org.jboss.mq.Connection] Starting connection, ClientID=ID:13
2004-02-10 16:22:33,894 TRACE [org.jboss.mq.server.TracingInterceptor] CALLED : setEnabled
2004-02-10 16:22:33,894 TRACE [org.jboss.mq.server.TracingInterceptor] ARG : true
2004-02-10 16:22:33,894 TRACE [org.jboss.mq.server.ClientConsumer] ClientConsumer:ID:13->setEnabled(enabled=true)
2004-02-10 16:22:33,894 TRACE [org.jboss.mq.server.TracingInterceptor] RETURN : setEnabled
2004-02-10 16:22:33,894 DEBUG [org.jboss.resource.adapter.jms.JmsManagedConnection] transacted=true, ack=1
2004-02-10 16:22:33,894 DEBUG [org.jboss.resource.adapter.jms.JmsManagedConnection] ConnectionEvent listener added: org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener@14790be
2004-02-10 16:22:34,155 TRACE [org.jboss.mq.SpyXAResourceManager] Adding xid=null, message=org.jboss.mq.SpyObjectMessage {
Header {
jmsDestination : QUEUE.com.betweenmarkets.registry.ebxml.event.EventManagerMessageQueue
jmsDeliveryMode : 2
jmsExpiration : 0
jmsPriority : 4
jmsMessageID : ID:13-10764517540841
jmsTimeStamp : 1076451754084
jmsCorrelationID: null
jmsReplyTo : null
jmsType : null
jmsRedelivered : false
jmsProperties : {}
jmsPropertiesReadWrite:true
msgReadOnly : false
producerClientId: ID:13
}
}
2004-02-10 16:22:34,155 TRACE [org.jboss.mq.SpyXAResourceManager] TXState=null
2004-02-10 16:22:34,155 ERROR [STDERR] javax.jms.JMSException: Invalid transaction id.
2004-02-10 16:22:34,155 ERROR [STDERR] at org.jboss.mq.SpyXAResourceManager.addMessage(SpyXAResourceManager.java:95)
2004-02-10 16:22:34,155 ERROR [STDERR] at org.jboss.mq.SpySession.sendMessage(SpySession.java:732)
2004-02-10 16:22:34,155 ERROR [STDERR] at org.jboss.mq.SpyQueueSender.internalSend(SpyQueueSender.java:118)
2004-02-10 16:22:34,155 ERROR [STDERR] at org.jboss.mq.SpyQueueSender.send(SpyQueueSender.java:68)
2004-02-10 16:22:34,155 ERROR [STDERR] at com.betweenmarkets.services.rosettanet.unpacker.handler.integration.BarePIP20XmlHandler.shootNewEvent(BarePIP20XmlHandler.java:247)
2004-02-10 16:22:34,155 ERROR [STDERR] at com.betweenmarkets.services.rosettanet.unpacker.handler.integration.BarePIP20XmlHandler.handle(BarePIP20XmlHandler.java:220)
2004-02-10 16:22:34,155 ERROR [STDERR] at com.betweenmarkets.unpacker.UnpackerBean.onMessage(UnpackerBean.java:130)
2004-02-10 16:22:34,155 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2004-02-10 16:22:34,155 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2004-02-10 16:22:34,155 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2004-02-10 16:22:34,175 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
2004-02-10 16:22:34,175 ERROR [STDERR] at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.java:460)
2004-02-10 16:22:34,175 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
2004-02-10 16:22:34,175 ERROR [STDERR] at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstanceInterceptor.java:62)
2004-02-10 16:22:34,175 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
2004-02-10 16:22:34,205 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:240)
2004-02-10 16:22:34,205 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
2004-02-10 16:22:34,205 ERROR [STDERR] at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:90)
2004-02-10 16:22:34,205 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
2004-02-10 16:22:34,205 ERROR [STDERR] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
2004-02-10 16:22:34,225 ERROR [STDERR] at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:374)
2004-02-10 16:22:34,225 ERROR [STDERR] at org.jboss.ejb.Container.invoke(Container.java:700)
2004-02-10 16:22:34,225 ERROR [STDERR] at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.java:824)
2004-02-10 16:22:34,235 ERROR [STDERR] at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(JMSContainerInvoker.java:1114)
2004-02-10 16:22:34,235 ERROR [STDERR] at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:256)
2004-02-10 16:22:34,255 ERROR [STDERR] at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:633)
2004-02-10 16:22:34,255 ERROR [STDERR] at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:433)
2004-02-10 16:22:34,255 ERROR [STDERR] at org.jboss.mq.SpySession.run(SpySession.java:302)
2004-02-10 16:22:34,255 ERROR [STDERR] at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:180)
2004-02-10 16:22:34,315 ERROR [STDERR] at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:727)
2004-02-10 16:22:34,335 ERROR [STDERR] at java.lang.Thread.run(Thread.java:534)
---------------------------------------------------------------------------------
And here are the relevant pieces of the ejb-jar.xml
<message-driven>
<ejb-name>UnpackerBean</ejb-name>
<ejb-class>com.betweenmarkets.unpacker.UnpackerBean</ejb-class>
<transaction-type>Container</transaction-type>
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
</message-driven-destination>
<resource-ref>
<res-ref-name>jms/XAQueueConnection</res-ref-name>
<res-type>javax.jms.QueueConnectionFactory</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
The Event Queue
<res-ref-name>jms/EventQueue</res-ref-name>
<res-type>javax.jms.Queue</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</message-driven>
------------------------------------------------------------------------------
And here are the relevant pieces of the jboss.xml:
<message-driven>
<ejb-name>UnpackerBean</ejb-name>
<configuration-name>Singleton Message Driven Bean</configuration-name>
<destination-jndi-name>queue/com.betweenmarkets.unpacker.UnpackerMessageQueue</destination-jndi-name>
<resource-ref>
<res-ref-name>jms/XAQueueConnection</res-ref-name>
<resource-name>queuefactoryref</resource-name>
</resource-ref>
<resource-ref>
<res-ref-name>jms/EventQueue</res-ref-name>
<resource-name>queueref</resource-name>
</resource-ref>
</message-driven>
....
<resource-managers>
<resource-manager>
<res-name>queuefactoryref</res-name>
<res-jndi-name>java:/JmsXA</res-jndi-name>
</resource-manager>
<resource-manager>
<res-name>queueref</res-name>
<res-jndi-name>queue/com.betweenmarkets.registry.ebxml.event.EventManagerMessageQueue</res-jndi-name>
</resource-manager>
</resource-managers>
------------------------------------------------------------------------------------
And here are the relevant parts of the code:
InitialContext context = new InitialContext();
Queue queue = (Queue)context.lookup
("java:comp/env/jms/EventQueue");
QueueConnectionFactory factory = (QueueConnectionFactory)
context.lookup("java:comp/env/jms/XAQueueConnection");
QueueConnection queueConnection = factory.createQueueConnection();
QueueSession queueSession = queueConnection.
createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
ObjectMessage message = queueSession.createObjectMessage(
new NewBusinessDocumentEvent(newDocumentUuid));
QueueSender sender = queueSession.createSender(queue);
sender.send(message);
-----------------------------------------------------------------------------------
Any ideas or suiggestions would be greatly appreciated, and thanks to all in advance,
-Steven Vaughan