tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jean-Claude Haw-King-Chon <>
Subject Tomcat7 - ajax and connection pool : "connection closed" despite the use of "validationQuery" and "testOnBorrow"
Date Fri, 05 Apr 2013 09:37:30 GMT

I use the connection pool of tomcat7 and set a connection in a 
ThreadLocal. The context is a web application : the threadLocal is 
configured when the http request is initialized. The jdbc connection is 
closed and removed from the threadLocal when the resquest is destroyed.

If I'm not mistaken, each http request is treated by one thread by 
tomcat. So, I have one jdbc connection for each request ( = thread).

My problem appears when I use Ajax. For 2 successive ajax request, I 
have the error "Connection closed" : it's a random problem (the 
stacktrace is not the same for the 2 attemps and it's not depending of 
the thread execution order).

I know this issue :

"These can occur when one request gets a db connection from the 
connection pool and closes it twice. When using a connection pool, 
closing the connection just returns it to the pool for reuse by another 
request, it doesn't close the connection. And Tomcat uses multiple 
threads to handle concurrent requests"

But, I'm sure, I always close the connection only once.
I use too the "validationQuery" and "testOnBorrow" parameters.

Is it possible that the connection pool returns the same connection for 
2 different threads?

So I don't understand why my connection is closed during the treatment.

Thank for your help

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message