I am using WAS 7.1 along with c3p0 (v 0.9.2.1) & hibernate (3.2.6ga)
After some hours of usage Websphere hangs and I see this message in the log
[6/24/13 10:57:50:377 CEST] 00000031 ThreadMonitor W WSVR0605W: Thread "WebContainer : 24" (00000048) has been active for 759356 milliseconds and may be hung. There is/are 45 thread(s) in total in the server that may be hung.
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:196)
at com.mchange.v2.resourcepool.BasicResourcePool.awaitAcquire(BasicResourcePool.java:776)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:198)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:170)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:172)
at com.mchange.v2.c3p0.PoolBackedDataSource.getConnection(PoolBackedDataSource.java:58)
at org.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:56)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:119)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
at com.aaa.in.bbb.effort.daoImpl.GRDAO.getGroupList(GRDAO.java:60)
at com.aaa.in.bbb.effort.delegate.GRBean.getGroupList(GRBean.java:40)
at com.aaa.in.bbb.effort.action.GRAction.execute(GRAction.java:74)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1658)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:940)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:503)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:181)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3954)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:942)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1592)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:453)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:515)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:306)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:277)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1646)
I have no idea why the session is not closed. Here is the session code
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
Context ctx = new InitialContext();
Object obj = ctx.lookup("HibernateSessionFactory");
sessionFactory = (SessionFactory) obj;
} catch (Throwable ex) {
System.out.println("Initial SessionFactory creation failed: "
+ ex.getMessage());
throw new ExceptionInInitializerError(ex);
}
}
public static final ThreadLocal hibernateSession = new ThreadLocal();
public static Session currentSession() {
Session s = (Session) sessionFactory.openSession();
hibernateSession.set(s);
return s;
}
public static void closeSession() {
Session s = (Session) hibernateSession.get();
try {
if(s != null)
{
hibernateSession.set(null);
s.close();
System.out.println("s!=null");
}
} catch (HibernateException e) {
e.printStackTrace();
System.out.println("Error occured in closesession()");
}
finally
{
s=null;
}
}
public static void closeSession(Session session) {
try {
if(session != null)
{
session.flush();
hibernateSession.set(null);
session.close();
session=null;
}
} catch (HibernateException e) {
e.printStackTrace();
System.out.println("Error occured in closesession(session)");
}
}
}
I checked the code and the request to close session is there but somehow the session itself is not being released by C3P0
The problem happens only after I introduced connection pooling. The reason I had to introduce connection pooling was to solve the max cursors errors reached in Oracle 11 (see Max cursors reached error in JSP + Hibernate)
has any one faced this errors? Any pointers?