-->
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.  [ 1 post ] 
Author Message
 Post subject: WebSphere StaleConnectionException fix
PostPosted: Thu Mar 25, 2004 3:59 pm 
Beginner
Beginner

Joined: Wed Aug 27, 2003 8:55 am
Posts: 28
Location: Dallas, TX
This topic has actually been discussed before and a solution is posted as a FAQ. However, this solution does not provide a reasoning behind it, so I thought I would follow up just to clarify.

We have been experiencing a StaleConnectionException for some time, and we narrowed it down to WebSphere's pooling as the culprit (surprise - kind of like when we discovered that itn always gives you a Connection with autocommit set to true). Today, I read this in their Connection Pool documentation (WebSphere 4, but this probably applies to WS 5, too):

Code:
DISABLE_AUTO_CONN_CLEANUP - Specifies whether or not the connection is closed at the end of a transaction. The default is false, which indicates that when a transaction is completed, WebSphere connection pooling closes the connection and all associated resources and returns the connection to the pool. This means that any use of the connection after the transaction has ended results in a StaleConnectionException, because the connection has been closed and returned to the pool. This mechanism ensures that connections are not held indefinitely by the application. If the value is set to true, the connection is not returned to the pool at the end of a transaction. In this case, the application must return the connection to the pool by explicitly calling close(). If the application does not close the connection, the pool will run out of connections for other applications to use. This is different from orphaning connections, because connections in a transaction cannot be orphaned.


I'm not sure why this is the default behavior. For our web application, we are using one ThreadLocal Session (Spring's OpenSessionInView helper class) for an entire web request. For some requests, multiple database transaction occur. Since we have "Disable Auto Cleanup" set to false, it appears that when our first transaction commits, WebSphere effectively closes the Connection and returns it to the pool. Yuck!

Anyway, thought I would try to clear things up for anybody wondering why checking this option makes the problem go away.

Ryan


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

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.