Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

starting a transacted session

10 views
Skip to first unread message

Daisy Guo

unread,
Oct 24, 2002, 1:29:35 PM10/24/02
to
I created a transacted session, published a few messages, but when tried to
rollback the transaction, weblogic complained about "No transaction" --
XAConnectionFactory was Enabled, and session created with
conn.createTopicSession(true, Session.AUTO_ACKNOWLEDGE), but calling
session.getTransacted() did return false! Please help!

This the snip from config.xml:
<JMSConnectionFactory JNDIName="jms/XATopicConnectionFactory"
Name="XA Topic Connection Factory" Targets="jmsServer"
TransactionTimeout="0" UserTransactionsEnabled="true"
XAConnectionFactoryEnabled="true" XAServerEnabled="true"/>

and code causing the exception (in a servlet):
ctx = new InitialContext();
factory = (TopicConnectionFactory)
ctx.lookup("jms/XATopicConnectionFactory");
conn = factory.createTopicConnection();
session = conn.createTopicSession(true,
Session.AUTO_ACKNOWLEDGE);
System.out.println("Transacted session? " +
session.getTransacted());
topic = (Topic) ctx.lookup(TOPIC);
TopicPublisher publisher;
TextMessage mMsg;
for (int i=1; i<5; i++){
mMsg = session.createTextMessage( "Message No. " + i);
publisher = session.createPublisher(topic);
publisher.publish(mMsg);
if (i==3){
session.commit();
}
}
session.rollback();

Weblogic's complain:
*********false
weblogic.jms.common.IllegalStateException: No transaction
at weblogic.jms.client.JMSXASession.commit(JMSXASession.java:59)
at
test.jms.transaction.xa.XATransactionTestServlet.doGet(XATransactionT
estServlet.java:167)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:945)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:332)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:242)
at
weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:5363)
at
weblogic.security.service.SecurityServiceManager.runAs(SecurityServic
eManager.java:721)
at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:3043)
at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2466)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:152)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:133)


Tom Barnes

unread,
Oct 24, 2002, 5:16:32 PM10/24/02
to Daisy Guo
Hi Daisy,

As per the JMS spec, XASessions can not be transacted, and the transacted
flag is ignored. I think you are creating an XASession unawares as you are
actually
getting an XAConnection from createTopicConnection, and then in turn
using this XAConnection to create the session. This behavior is caused
by the "XAServerEnabled" flag. Either don't use an XA factory at all or set
this
particular flag to false.

For more on "transacted sessions" vs. "user transaction aware sessions" (which,
despite
the unfortunate similarity in names, are significantly different) see the JMS
FAQ.

Tom

0 new messages