Invalid transaction id - XAConnectionFactory, ...
lion78at Dec 16, 2002 5:14 PMHello!
I want to implement a method in a session bean which sends object-messages to a queue. The transaction-type of the method should be "container-managed, required". I use the following code, which produces an "Invalid transaction id." error:
public void sendObjectMessage(Serializable serObject) {
try {
InitialContext ictxBean=new InitialContext();
XAQueueConnectionFactory xqcnfcMessaging=(XAQueueConnectionFactory)ictxBean.lookup("XAConnectionFactory");
XAQueueConnection xqcnMessaging=xqcnfcMessaging.createXAQueueConnection();
XAQueueSession xqsesMessaging=xqcnMessaging.createXAQueueSession();
QueueSender qsenMessaging=xqsesMessaging.getQueueSession().createSender(null);
Queue queMessaging=(Queue)ictxBean.lookup("java:comp/env/jms/myQueue");
ObjectMessage omMessaging=xqsesMessaging.createObjectMessage();
omMessaging.setObject(serObject);
qsenMessaging.send(queMessaging,omMessaging);
qsenMessaging.close();
xqsesMessaging.close();
xqcnMessaging.close();
}
catch (Exception jmse) {
coLogger.error("sendObjectMessage >> Can't send object message.",jmse);
throw new EJBException("Can't send object message: "+jmse.getMessage());
}
}
Here the corresponding exception:
javax.jms.JMSException: Invalid transaction id.
at org.jboss.mq.SpyXAResourceManager.addMessage(SpyXAResourceManager.java:93)
at org.jboss.mq.SpySession.sendMessage(SpySession.java:651)
at org.jboss.mq.SpyQueueSender.internalSend(SpyQueueSender.java:118)
at org.jboss.mq.SpyQueueSender.send(SpyQueueSender.java:84)
at at.intervista.pvm.session.ManageMessagingBean.sendObjectMessage(ManageMessagingBean.java:67)
at at.intervista.pvm.session.ManageMessagingBean.sendTrafficMessageToQueue(ManageMessagingBean.java:51)
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:660)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:77)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:178)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:60)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:313)
at org.jboss.ejb.Container.invoke(Container.java:712)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:382)
at sun.reflect.GeneratedMethodAccessor53.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:536)
My questions:
1. Whats wrong with my code?
2. Can I do this (session-bean, container-managed-transaction, required) easier?
Thanks und greetings, Bernhard.