2016-02-16 143 views
2

這對我來說已經開始成爲一個大問題。休眠10到12小時後休眠連接丟失

如果網站是不用於像10-12小時加。那麼出現這種錯誤,並且 ..

只有這樣,後沒有休眠的連接可以使現場工作又是通過重新啓動域

[2016-02-16T08:50:57.729+0530] [glassfish 4.1] [WARN] [] [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] [tid: _ThreadID=26 _ThreadName=http-listener-1(2)] [timeMillis: 1455592857729] [levelValue: 900] [[ 
    SQL Error: 0, SQLState: 08S01]] 

[2016-02-16T08:50:57.730+0530] [glassfish 4.1] [ERROR] [] [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] [tid: _ThreadID=26 _ThreadName=http-listener-1(2)] [timeMillis: 1455592857730] [levelValue: 1000] [[ 
    The last packet successfully received from the server was 36,572,564 milliseconds ago. The last packet sent successfully to the server was 36,572,565 milliseconds ago. 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.]] 

[2016-02-16T08:50:57.752+0530] [glassfish 4.1] [WARNING] [] [javax.enterprise.web] [tid: _ThreadID=26 _ThreadName=http-listener-1(2)] [timeMillis: 1455592857752] [levelValue: 900] [[ 
    StandardWrapperValve[Home]: Servlet.service() for servlet Home threw exception 
org.hibernate.exception.JDBCConnectionException: could not extract ResultSet 
    at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:132) 
    at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49) 
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126) 
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112) 
    at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:89) 
    at org.hibernate.loader.Loader.getResultSet(Loader.java:2065) 
    at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1862) 
    at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1838) 
    at org.hibernate.loader.Loader.doQuery(Loader.java:909) 
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:354) 
    at org.hibernate.loader.Loader.doList(Loader.java:2551) 
    at org.hibernate.loader.Loader.doList(Loader.java:2537) 
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2367) 
    at org.hibernate.loader.Loader.list(Loader.java:2362) 
    at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:126) 
    at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1678) 
    at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:380) 
    at opController.Home.getLogin(Home.java:93) 
    at opController.Home.doPost(Home.java:61) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) 
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:344) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) 
    at org.glassfish.tyrus.servlet.TyrusServletFilter.doFilter(TyrusServletFilter.java:305) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) 
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) 
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673) 
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) 
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283) 
    at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459) 
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167) 
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206) 
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180) 
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235) 
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111) 
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) 
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536) 
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137) 
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591) 
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 36,572,564 milliseconds ago. The last packet sent successfully to the server was 36,572,565 milliseconds ago. 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. 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422) 
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) 
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1117) 
    at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3871) 
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2484) 
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2664) 
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2794) 
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155) 
    at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2322) 
    at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:116) 
    at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:80) 
    ... 49 more 
Caused by: java.net.SocketException: Broken pipe 
    at java.net.SocketOutputStream.socketWrite0(Native Method) 
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109) 
    at java.net.SocketOutputStream.write(SocketOutputStream.java:153) 
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82) 
    at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140) 
    at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3852) 
    ... 56 more 
]] 

..

[2016-02-16T08:51:50.287+0530] [glassfish 4.1] [WARNING] [] [com.mchange.v2.c3p0.impl.NewPooledConnection] [tid: _ThreadID=27 _ThreadName=http-listener-1(3)] [timeMillis: 1455592910287] [levelValue: 900] [[ 
     [c3p0] A PooledConnection that has already signalled a Connection error is still in use!]] 

    [2016-02-16T08:51:50.290+0530] [glassfish 4.1] [WARNING] [] [com.mchange.v2.c3p0.impl.NewPooledConnection] [tid: _ThreadID=27 _ThreadName=http-listener-1(3)] [timeMillis: 1455592910290] [levelValue: 900] [[ 
     [c3p0] Another error has occurred [ com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 36,625,137 milliseconds ago. The last packet sent successfully to the server was 36,625,138 milliseconds ago. 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. ] which will not be reported to listeners! 
    com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 36,625,137 milliseconds ago. The last packet sent successfully to the server was 36,625,138 milliseconds ago. 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. 
     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 
     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
     at java.lang.reflect.Constructor.newInstance(Constructor.java:422) 
     at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) 
     at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1117) 
     at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3871) 
     at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2484) 
     at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2664) 
     at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2794) 
     at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155) 
     at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2322) 
     at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:116) 
     at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:80) 
     at org.hibernate.loader.Loader.getResultSet(Loader.java:2065) 
     at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1862) 
     at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1838) 
     at org.hibernate.loader.Loader.doQuery(Loader.java:909) 
     at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:354) 
     at org.hibernate.loader.Loader.doList(Loader.java:2551) 
     at org.hibernate.loader.Loader.doList(Loader.java:2537) 
     at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2367) 
     at org.hibernate.loader.Loader.list(Loader.java:2362) 
     at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:126) 
     at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1678) 
     at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:380) 
     at opController.Home.getLogin(Home.java:93) 
     at opController.Home.doPost(Home.java:61) 
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) 
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) 
     at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:344) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) 
     at org.glassfish.tyrus.servlet.TyrusServletFilter.doFilter(TyrusServletFilter.java:305) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) 
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316) 
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) 
     at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) 
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673) 
     at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) 
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) 
     at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416) 
     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283) 
     at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459) 
     at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167) 
     at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206) 
     at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180) 
     at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235) 
     at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) 
     at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283) 
     at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200) 
     at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132) 
     at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111) 
     at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) 
     at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536) 
     at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) 
     at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117) 
     at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56) 
     at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137) 
     at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591) 
     at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571) 
     at java.lang.Thread.run(Thread.java:745) 
    Caused by: java.net.SocketException: Broken pipe 
     at java.net.SocketOutputStream.socketWrite0(Native Method) 
     at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109) 
     at java.net.SocketOutputStream.write(SocketOutputStream.java:153) 
     at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82) 
     at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140) 
     at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3852) 
     ... 56 more 
    ]] 

我還張貼我的Hibernate配置文件了。

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> 
<hibernate-configuration> 
    <session-factory> 
     <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> 
     <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> 
     <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/db_name?autoReconnect=true</property> 
     <property name="hibernate.connection.username">user</property> 
     <property name="hibernate.connection.password">****</property> 
     <property name="hibernate.hbm2ddl.auto">validate</property> 
     <property name="show_sql">true</property> 
     <property name="format_sql">true</property> 
     <property name="hibernate.current_session_context_class">org.hibernate.context.internal.ThreadLocalSessionContext</property> 

     <!-- c3p0 Connection Pool Properties --> 
     <property name="hibernate.connection.pool_size">1</property> 
     <property name="hibernate.c3p0.min_size">1</property> 
     <property name="hibernate.c3p0.max_size">100</property> 
     <property name="hibernate.c3p0.timeout">0</property> 
     <property name="hibernate.c3p0.max_statements">0</property> 
     <property name="hibernate.c3p0.idle_test_period">0</property> 

     <mapping class="POJO.EXAMPLE"/> 
    </session-factory> 
</hibernate-configuration> 

回答