サーバー側のSpring BeanでExecutorServiceを利用しています。私が思う問題は、ExecutorService がプールのスレッドを作成するときに、接続プール (C3P0) から DB 接続も取得し、それを解放せず、しばらくすると接続がタイムアウトすることです。サーバーを起動すると、しばらくの間はすべて問題なく動作しますが、週末の後は例外です。
2012-07-09 11:12:10,825 ERROR [JDBCExceptionReporter] : The last packet successfully received from the server was259505 seconds ago.The last packet sent successfully to the server was 259505 seconds ago, which is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: could not execute query
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1215)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1148)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:255)
at za.co.bsg.ems.server.webservices.MWLWebServiceImpl.getUnpaidLeaveForms(ebff4f5 --------------:166)
at za.co.bsg.ems.server.webservices.MWLWebServiceImpl.access$300(ebff4f5 --------------:37)
at za.co.bsg.ems.server.webservices.MWLWebServiceImpl$2.run(ebff4f5 --------------:136)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.hibernate.exception.JDBCConnectionException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:99)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2536)
at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2319)
at org.hibernate.loader.Loader.list(Loader.java:2268)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:452)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:246)
... 6 more
実行が完了したときにスレッドが接続を解放しないのはなぜですか?