-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Websphere JTA and multiple session
PostPosted: Tue Feb 26, 2008 9:53 pm 
Newbie

Joined: Wed Aug 24, 2005 1:08 am
Posts: 8
We are using the session per conversation model. But we also need to load some data from a 2nd database.
We have done this successfully in a servlet. We just commit the TX for the conversation session, and start a new session/transaction from the other session factory. we load the data from the 2nd DB, close this new session/transaction, and finally begin a new transaction for the conversation session.

But when we try and do this in a JSP, it works fine until the JSP finishes rendering. At this point websphere appears to be doing a rollback on the JTA transaction, which results in the JDBCContext clearing its hibernate transaction. So when we return to the servlet, and try to commit the transaction for the conversation, its gone, and when the session creates a new one, it is set to begun=false



This is a stack trace from the end of JSP rendering. This is where JDBCContext.hibernateTransaction gets set to null;

JDBCContext.afterTransactionCompletion
CacheSynchronization.afterCompletion
RegisteredSyncs.distributeAfter
TransactionImpl.distributeAfter
TransactionImpl.postCompletion
TransactionImpl.internalRollback
TransactionImpl.rollback
TranManagerImpl.rollback
TranManagerSet.rollback
UserTransactionImpl.rollback
ServletWrapper.checkForRollback
ServletWrapper.checkTransaction
ServletWrapper.handleRequest
JSPExtentionServletWrapper.handleRequest
WebAppRequestDispatcher.forward

Hibernate version:
3.2.5 ga
Mapping documents:
na
Code between sessionFactory.openSession() and session.close():

In Servlet
create session from session factory 1 to use as conversation session
begin transaction for conversation session
load data from DB 1

In JSP:
get the transaction from the conversation session\
commit transaction
create session from session factory 2
begin transaction for new session
load data from DB 2
commit new transaction
close new session
begin new transaction for conversation session

in JSP:
get the transaction from the conversation session (The transaction has already been removed so it creates a new one with begun=false)
commit transaction (this errors because begug=false)


Full stack trace of any exception that occurs:
[27/02/08 12:50:01:911 EST] 0000003e SystemErr R org.hibernate.TransactionException: Transaction not successfully started
at org.hibernate.transaction.JTATransaction.commit(JTATransaction.java:126)
at com.creata.HibernateUtils.SessionManager.placeConversationOnHold(SessionManager.java:364)
at com.creata.TableEditor.TableEditorController.doGet(TableEditorController.java)
at com.creata.TableEditor.TableEditorServlet.doGet(TableEditorServlet.java:42)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1572)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:762)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:89)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1924)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:89)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:472)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:411)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:288)
at com.ibm.ws.ssl.channel.impl.SSLConnectionLink.determineNextChannel(SSLConnectionLink.java:950)
at com.ibm.ws.ssl.channel.impl.SSLConnectionLink$MyReadCompletedCallback.complete(SSLConnectionLink.java:582)
at com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1701)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:566)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java:619)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:952)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1039)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1471)
Name and version of the database you are using:
DB2 8.2.13
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject: Websphere JTA and multiple session
PostPosted: Wed Apr 30, 2008 3:17 am 
Beginner
Beginner

Joined: Wed Aug 09, 2006 12:09 pm
Posts: 20
Location: Belgium
Hello I am experiencing the same problem, did you get a resolve to this issue?

cheers
Martin


Top
 Profile  
 
 Post subject: I wish
PostPosted: Wed Apr 30, 2008 5:49 am 
Newbie

Joined: Wed Aug 24, 2005 1:08 am
Posts: 8
The only thing we have found to do is insure all the data from the 2nd DB is loaded in the servlet before we get to the JSP


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.