解決mysql自動斷掉連線的問題
HTTP Status 500 - org.hibernate.exception.JDBCConnectionException: The last packet successfully received from the server was 270,558,931 milliseconds ago. The last packet sent successfully to the server was 270,558,931 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.
type Exception report
message org.hibernate.exception.JDBCConnectionException: The last packet successfully received from the server was 270,558,931 milliseconds ago. The last packet sent successfully to the server was 270,558,931 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.
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: org.hibernate.exception.JDBCConnectionException: The last packet successfully received from the server was 270,558,931 milliseconds ago. The last packet sent successfully to the server was 270,558,931 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. org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515) org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:422)
root cause
org.hibernate.exception.JDBCConnectionException: The last packet successfully received from the server was 270,558,931 milliseconds ago. The last packet sent successfully to the server was 270,558,931 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. org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:131) org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49) org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125) org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110) org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:129) org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81) com.sun.proxy.$Proxy27.executeQuery(Unknown Source) org.hibernate.loader.Loader.getResultSet(Loader.java:1953) org.hibernate.loader.Loader.doQuery(Loader.java:829) org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289) org.hibernate.loader.Loader.doList(Loader.java:2438) org.hibernate.loader.Loader.doList(Loader.java:2424) org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2254) org.hibernate.loader.Loader.list(Loader.java:2249) org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:470) org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355) org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195) org.hibernate.internal.SessionImpl.list(SessionImpl.java:1248) org.hibernate.internal.QueryImpl.list(QueryImpl.java:101) hdfs.admin.util.LoginService.hasCompanyCode(LoginService.java:18) webadmin.struts.action.LoginAction.execute(LoginAction.java:132) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:606) com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:404) com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:267) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:229) com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:150) org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:48) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:123) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:184) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:105) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:83) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:207) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:74) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:127) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:107) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:206) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:115) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:143) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:121) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:170) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:123) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:50) org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:504) org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:422)
root cause
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 270,558,931 milliseconds ago. The last packet sent successfully to the server was 270,558,931 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. sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) java.lang.reflect.Constructor.newInstance(Constructor.java:526) com.mysql.jdbc.Util.handleNewInstance(Util.java:411) com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1121) com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3871) com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2484) com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2664) com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2815) com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155) com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2322) sun.reflect.GeneratedMethodAccessor63.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:606) org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122) org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81) com.sun.proxy.$Proxy27.executeQuery(Unknown Source) org.hibernate.loader.Loader.getResultSet(Loader.java:1953) org.hibernate.loader.Loader.doQuery(Loader.java:829) org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289) org.hibernate.loader.Loader.doList(Loader.java:2438) org.hibernate.loader.Loader.doList(Loader.java:2424) org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2254) org.hibernate.loader.Loader.list(Loader.java:2249) org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:470) org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355) org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195) org.hibernate.internal.SessionImpl.list(SessionImpl.java:1248) org.hibernate.internal.QueryImpl.list(QueryImpl.java:101) hdfs.admin.util.LoginService.hasCompanyCode(LoginService.java:18) webadmin.struts.action.LoginAction.execute(LoginAction.java:132) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:606) com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:404) com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:267) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:229) com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:150) org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:48) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:123) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:184) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:105) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:83) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:207) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:74) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:127) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:107) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:206) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:115) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:143) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:121) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:170) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:123) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:50) org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:504) org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:422)
root cause
java.net.SocketException: 斷開的管道 java.net.SocketOutputStream.socketWrite0(Native Method) java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113) java.net.SocketOutputStream.write(SocketOutputStream.java:159) java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82) java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140) com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3852) com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2484) com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2664) com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2815) com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155) com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2322) sun.reflect.GeneratedMethodAccessor63.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:606) org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122) org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81) com.sun.proxy.$Proxy27.executeQuery(Unknown Source) org.hibernate.loader.Loader.getResultSet(Loader.java:1953) org.hibernate.loader.Loader.doQuery(Loader.java:829) org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289) org.hibernate.loader.Loader.doList(Loader.java:2438) org.hibernate.loader.Loader.doList(Loader.java:2424) org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2254) org.hibernate.loader.Loader.list(Loader.java:2249) org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:470) org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355) org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195) org.hibernate.internal.SessionImpl.list(SessionImpl.java:1248) org.hibernate.internal.QueryImpl.list(QueryImpl.java:101) hdfs.admin.util.LoginService.hasCompanyCode(LoginService.java:18) webadmin.struts.action.LoginAction.execute(LoginAction.java:132) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:606) com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:404) com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:267) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:229) com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:150) org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:48) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:123) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:184) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:105) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:83) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:207) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:74) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:127) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:107) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:206) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:115) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:143) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:121) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:170) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:123) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:50) org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:504) org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:422) 參考了別人的一篇文章:http://blog.csdn.net/yufaw/article/details/7658485 問題本質上應該是一樣的。
這兩週做了個手機的後臺程式,資料庫為MySQL5.0,持久層使用Hibernate 3.0,沒有使用額外的連線池,那麼Hibernate會預設使用它自帶的一個預設連線池,也就是DriverManagerConnectionProvider。部署到伺服器上,沒發現什麼問題。等到第二天,同事呼叫介面時,提示錯誤,但是重啟tomcat後問題就解決了。前兩天沒有時間,今天又出現問題了,問題如下圖所示.
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.hibernate.exception.JDBCConnectionException: could not execute query org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:97) org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) org.hibernate.loader.Loader.doList(Loader.java:2235) org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129) org.hibernate.loader.Loader.list(Loader.java:2124) org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401) org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363) org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196) org.hibernate.impl.SessionImpl.list(SessionImpl.java:1149) org.hibernate.impl.QueryImpl.list(QueryImpl.java:102) com.swift.softwarestore.service.IConDownloadAction.doPost(IConDownloadAction.java:100) com.swift.softwarestore.service.IConDownloadAction.doGet(IConDownloadAction.java:76) javax.servlet.http.HttpServlet.service(HttpServlet.java:621) javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed due to underlying exception/error: ** BEGIN NESTED EXCEPTION ** com.mysql.jdbc.CommunicationsException MESSAGE: Communications link failure due to underlying exception: ** BEGIN NESTED EXCEPTION ** java.net.SocketException MESSAGE: 斷開的管道 STACKTRACE: java.net.SocketException: 斷開的管道 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:2744) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1612) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723) at com.mysql.jdbc.Connection.execSQL(Connection.java:3283) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332) at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1467) at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208) at org.hibernate.loader.Loader.getResultSet(Loader.java:1812) at org.hibernate.loader.Loader.doQuery(Loader.java:697) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259) at org.hibernate.loader.Loader.doList(Loader.java:2232) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129) at org.hibernate.loader.Loader.list(Loader.java:2124) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401) 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:1149) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102) at com.swift.softwarestore.service.SoftwareInfoAction.doprint(SoftwareInfoAction.java:146) at com.swift.softwarestore.service.SoftwareInfoAction.doPost(SoftwareInfoAction.java:86) at javax.servlet.http.HttpServlet.service(HttpServlet.java:641) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) ** END NESTED EXCEPTION ** Last packet sent to the server was 1 ms ago. STACKTRACE: com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: ** BEGIN NESTED EXCEPTION ** java.net.SocketException MESSAGE: 斷開的管道 STACKTRACE: java.net.SocketException: 斷開的管道 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:2744) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1612) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723) at com.mysql.jdbc.Connection.execSQL(Connection.java:3283) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332) at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1467) at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208) at org.hibernate.loader.Loader.getResultSet(Loader.java:1812) at org.hibernate.loader.Loader.doQuery(Loader.java:697) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259) at org.hibernate.loader.Loader.doList(Loader.java:2232) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129) at org.hibernate.loader.Loader.list(Loader.java:2124) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401) 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:1149) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102) at com.swift.softwarestore.service.SoftwareInfoAction.doprint(SoftwareInfoAction.java:146) at com.swift.softwarestore.service.SoftwareInfoAction.doPost(SoftwareInfoAction.java:86) at javax.servlet.http.HttpServlet.service(HttpServlet.java:641) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) ** END NESTED EXCEPTION ** Last packet sent to the server was 1 ms ago. at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2759) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1612) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723) at com.mysql.jdbc.Connection.execSQL(Connection.java:3283) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332) at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1467) at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208) at org.hibernate.loader.Loader.getResultSet(Loader.java:1812) at org.hibernate.loader.Loader.doQuery(Loader.java:697) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259) at org.hibernate.loader.Loader.doList(Loader.java:2232) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129) at org.hibernate.loader.Loader.list(Loader.java:2124) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401) 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:1149) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102) at com.swift.softwarestore.service.SoftwareInfoAction.doprint(SoftwareInfoAction.java:146) at com.swift.softwarestore.service.SoftwareInfoAction.doPost(SoftwareInfoAction.java:86) at javax.servlet.http.HttpServlet.service(HttpServlet.java:641) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) ** END NESTED EXCEPTION ** com.mysql.jdbc.SQLError.createSQLException(SQLError.java:888) com.mysql.jdbc.Connection.checkClosed(Connection.java:1932) com.mysql.jdbc.Connection.prepareStatement(Connection.java:4768) com.mysql.jdbc.Connection.prepareStatement(Connection.java:4734) org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:534) org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:452) org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161) org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1577) org.hibernate.loader.Loader.doQuery(Loader.java:696) org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259) org.hibernate.loader.Loader.doList(Loader.java:2232) org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129) org.hibernate.loader.Loader.list(Loader.java:2124) org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401) org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363) org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196) org.hibernate.impl.SessionImpl.list(SessionImpl.java:1149) org.hibernate.impl.QueryImpl.list(QueryImpl.java:102) com.swift.softwarestore.service.IConDownloadAction.doPost(IConDownloadAction.java:100) com.swift.softwarestore.service.IConDownloadAction.doGet(IConDownloadAction.java:76) javax.servlet.http.HttpServlet.service(HttpServlet.java:621) javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.27 logs.
在網上查了查,說是需要修改mysql的配置檔案my.cnf.原因是mysql預設8個小時內無請求就斷掉連線。需要在mysqld後新增wait_timeout=172800,interactive_timeout=172800這兩行配置引數,但是後來發現這樣也不能除根啊。
在網上找的解決方案:
當時也搞不清楚為什麼,但重啟Tomcat後就一切回覆正常了,但是又過了一天,問題再次出現。仔細分析錯誤資訊,問題肯定出在資料庫連線部分,在網上查閱大量資訊後,明確了問題的原因:MySQL對所有連線的有效時間預設為28800秒,正好8小時,也就是說,如果一個連線8小時沒有請求和操作,就會自動斷開;但是對於Hibernate來說,它的連線池並不知道它所管理的連線中是否有被MySQL斷開的。如果一個程式要使用資料庫連線,而Hibernte的連線池分配一個已經被MySQL斷開了的給程式使用,那麼便會出現錯誤。
為了證實確實是這個錯誤,我在本機上做了如下測試:首先啟動Tomcat,網站能夠正常開啟;然後修改系統時間,往後調1天;然後再開啟網站,同樣的問題果然出現!MySQL + Hibernate架構相當普遍,所以這個問題也相當普遍,若讀者也有這樣的專案,建議做一下同樣的測試,看看是否存在此問題!
問題找到了,怎麼解決呢?
思路1:增大MySQL的連線有效時間;
思路2:從程式自身出發,修改連線池的相關引數。
顯然,思路1是不可行的,一方面這個思路不可能保證這個問題絕對的解決,如果無訪問時間夠長,還是大於MySQL的連線有效時間,問題同樣會發生;另一方面,一般情況下,我們都是將程式部署在別人伺服器上,我們不可能去修改MySQL配置。那麼只能從思路2入手了。
經查資料發現,Hibernate支援如下的連線池:
DriverManagerConnectionProvider:代表由Hibernate提供的預設的資料庫連線池
C3P0ConnectionProvider:代表C3P0連線池
ProxoolConnectionProvider:代表Proxool連線池
DBCPConnectionProvider:代表DBCP連線池
DatasourceConnectionProvider:代表在受管理環境中由容器提供的資料來源
其中,預設連線池並不支援在分配一個連線時,測試其有效與否的功能,而C3P0、Proxool、DBCP都提供了這樣的功能,正好可以解決上述問題。綜合考慮各個連線池的效率、穩定性、易用性,決定換用Proxool,它確實在各方面表現優良,方便配置。
下面就看看如何配置Proxool:
1、Hibernate配置檔案:
<session-factory><property name="hibernate.connection.provider_class">org.hibernate.connection.ProxoolConnectionProvider</property><property name="hibernate.proxool.xml">proxool.xml</property><property name="hibernate.proxool.pool_alias">mysql</property>
<property name="show_sql">false</property><property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<mapping resource="com/lab1000/jcom/pojo/Admin.hbm.xml" />...</session-factory>
其中各屬性含義如下:
hibernate.connection.provider_class:指明使用Proxool連線池
hibernate.proxool.xml:指明Proxool配置檔案所在位置,這裡與Hibernate的配置檔案在同一目錄下
hibernate.proxool.pool_alias:指明要使用的proxool.xml中定義的proxool別名。
2、Proxool配置檔案(proxool.xml):
<?xml version="1.0" encoding="UTF-8"?> <!-- the proxool configuration can be embedded within your own application's. Anything outside the "proxool" tag is ignored. --> <something-else-entirely> <proxool>
<!-- proxool別名 --><alias>mysql</alias>
<!-- 資料庫連線Url --><driver-url> jdbc:mysql://localhost/yourDatebase?useUnicode=true&characterEncoding=UTF-8</driver-url>
<!-- JDBC驅動名稱 --><driver-class>com.mysql.jdbc.Driver</driver-class>
<!-- 資料庫連線帳號 --><driver-properties> <property name="user" value="root" /> <property name="password" value="password" /></driver-properties>
<!-- proxool自動偵察各個連線狀態的時間間隔(毫秒),偵察到空閒的連線就馬上回收,超時的銷燬 --><house-keeping-sleep-time>90000</house-keeping-sleep-time>
<!-- 指因未有空閒連線可以分配而在佇列中等候的最大請求數,超過這個請求數的使用者連線就不會被接受 --> <maximum-new-connections>20</maximum-new-connections>
<!-- 最少保持的空閒連線數 --><prototype-count>3</prototype-count>
<!-- 允許最大連線數,超過了這個連線,再有請求時,就排在佇列中等候,最大的等待請求數由maximum-new-connections決定 --><maximum-connection-count>20</maximum-connection-count>
<!-- 最小連線數 --><minimum-connection-count>3</minimum-connection-count>
<!-- 在分配連線前後是否進行有效性測試,這個是解決本問題的關鍵 --><test-before-use>true</test-before-use><test-after-use>true</test-after-use>
<!-- 用於測試的SQL語句 --><house-keeping-test-sql>SELECT CURRENT_USER</house-keeping-test-sql>
</proxool> </something-else-entirely>
3、下載和安裝Proxool的包檔案
下載地址:http://proxool.sourceforge.net/download.html
下載後並解壓後,將其中lib資料夾下的jar檔案拷貝到你站點的WEB-INF/lib下
修改如下JDBC連線的 URL:
jdbc:mysql://hostaddress:3306/schemaname?autoReconnec