web-dev-qa-db-fra.com

MySQLNonTransientConnectionException: Aucune opération autorisée après la fermeture de la connexion. Connexion

J'ai construit une application Web et déployé localement fonctionnant parfaitement. Je l'ai déployé sur un serveur distant et j'ai commencé à recevoir l'exception suivante:

> javax.servlet.ServletException: could not execute query 
org.Apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.Java:518) 
org.Apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.Java:421) 


>root cause 

>org.hibernate.exception.JDBCConnectionException: could not execute query 
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.Java:74) 
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.Java:43) 
org.hibernate.loader.Loader.doList(Loader.Java:2223) 
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.Java:2104) 
org.hibernate.loader.Loader.list(Loader.Java:2099) 
org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.Java:94) 
org.hibernate.impl.SessionImpl.list(SessionImpl.Java:1569) 
org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.Java:283) 
data.dao.UserDAO.findByUsername(UserDAO.Java:42) 
action.registration.LoginAction.execute(LoginAction.Java:24) 
Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:39) 
Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:25) 
Java.lang.reflect.Method.invoke(Method.Java:597) 
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.Java:399) 
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.Java:262) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:224) 
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.Java:213) 
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.Java:86) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
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:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.Java:123) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
com.opensymphony.xwork2.interceptor.ParametersInterceptor.intercept(ParametersInterceptor.Java:161) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.Java:105) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
org.Apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.Java:83) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
org.Apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.Java:207) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.Java:74) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.Java:127) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
org.Apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.Java:107) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
org.Apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.Java:206) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.Java:115) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.Java:143) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
com.opensymphony.xwork2.interceptor.PrepareInterceptor.intercept(PrepareInterceptor.Java:115) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
org.Apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.Java:170) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.Java:123) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.Java:176) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
org.Apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.Java:50) 
org.Apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.Java:507) 
org.Apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.Java:421) 

>root cause 

>com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed due to underlying exception/error: 


** BEGIN NESTED EXCEPTION ** 
    >com.mysql.jdbc.exceptions.jdbc4.CommunicationsException 
MESSAGE: Communications link failure 

>Last packet sent to the server was 43 ms ago. 

>STACKTRACE: 

>com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 

>Last packet sent to the server was 43 ms ago. 
at Sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
at Sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.Java:39) 
at Sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.Java:27) 
at Java.lang.reflect.Constructor.newInstance(Constructor.Java:513) 
at com.mysql.jdbc.Util.handleNewInstance(Util.Java:406) 
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.Java:1074) 
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.Java:2985) 
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.Java:2871) 
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.Java:3414) 
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.Java:1936) 
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.Java:2060) 
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.Java:2542) 
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.Java:1734) 
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.Java:1885) 
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.Java:186) 
at org.hibernate.loader.Loader.getResultSet(Loader.Java:1787) 
at org.hibernate.loader.Loader.doQuery(Loader.Java:674) 
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.Java:236) 
at org.hibernate.loader.Loader.loadEntity(Loader.Java:1860) 
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.Java:48) 
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.Java:42) 
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.Java:3042) 
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.Java:395) 
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.Java:375) 
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.Java:139) 
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.Java:195) 
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.Java:103) 
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.Java:878) 
at org.hibernate.impl.SessionImpl.get(SessionImpl.Java:815) 
at org.hibernate.impl.SessionImpl.get(SessionImpl.Java:808) 
at data.base._BaseRootDAO.get(_BaseRootDAO.Java:228) 
at data.base._BaseRootDAO.get(_BaseRootDAO.Java:217) 
at data.base.BaseUserDAO.get(BaseUserDAO.Java:49) 
at util.UserUtil.getUser(UserUtil.Java:22) 
at action.market.ArmsDealerAction.display(ArmsDealerAction.Java:62) 
at action.market.ArmsDealerAction.displayUser(ArmsDealerAction.Java:54) 
at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:39) 
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:25) 
at Java.lang.reflect.Method.invoke(Method.Java:597) 
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.Java:399) 
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.Java:262) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:224) 
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.Java:213) 
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.Java:86) 
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.Java:150) 
at org.Apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.Java:48) 
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.Java:86) 
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.Java:123) 
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.intercept(ParametersInterceptor.Java:161) 
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.Java:105) 
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
at org.Apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.Java:83) 
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
at org.Apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.Java:207) 
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.Java:74) 
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.Java:127) 
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
at org.Apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.Java:107) 
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
at 
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.Java:123) 
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.Java:176) 
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
org.Apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.Java:188) 
at org.Apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.Java:213) 
at org.Apache.catalina.core.StandardContextValve.invoke(StandardContextValve.Java:174) 
at org.Apache.catalina.core.StandardHostValve.invoke(StandardHostValve.Java:127) 
at org.Apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.Java:117) 
at org.Apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.Java:108) 
at org.Apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.Java:151) 
at org.Apache.coyote.http11.Http11Processor.process(Http11Processor.Java:874) 
at org.Apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.Java:665) 
at org.Apache.Tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.Java:528) 
at org.Apache.Tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.Java:81) 
at org.Apache.Tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.Java:689) 
at Java.lang.Thread.run(Thread.Java:619) 
Caused by: Java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost. 
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.Java:2431) 
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.Java:2882) 
... 141 more 


** END NESTED EXCEPTION ** 


>Sun.reflect.GeneratedConstructorAccessor72.newInstance(Unknown Source) 
Sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.Java:27) 
Java.lang.reflect.Constructor.newInstance(Constructor.Java:513) 
com.mysql.jdbc.Util.handleNewInstance(Util.Java:406) 
com.mysql.jdbc.Util.getInstance(Util.Java:381) 
com.mysql.jdbc.SQLError.createSQLException(SQLError.Java:984) 
com.mysql.jdbc.SQLError.createSQLException(SQLError.Java:956) 
com.mysql.jdbc.SQLError.createSQLException(SQLError.Java:926) 
com.mysql.jdbc.ConnectionImpl.checkClosed(ConnectionImpl.Java:1098) 
com.mysql.jdbc.ConnectionImpl.prepareStatement(ConnectionImpl.Java:4076) 
com.mysql.jdbc.ConnectionImpl.prepareStatement(ConnectionImpl.Java:4042) 
org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.Java:505) 
org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.Java:423) 
org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.Java:139) 
org.hibernate.loader.Loader.prepareQueryStatement(Loader.Java:1547) 
org.hibernate.loader.Loader.doQuery(Loader.Java:673) 
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.Java:236) 
org.hibernate.loader.Loader.doList(Loader.Java:2220) 
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.Java:2104) 
org.hibernate.loader.Loader.list(Loader.Java:2099) 
org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.Java:94) 
org.hibernate.impl.SessionImpl.list(SessionImpl.Java:1569) 
org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.Java:283) 
data.dao.UserDAO.findByUsername(UserDAO.Java:42) 
action.registration.LoginAction.execute(LoginAction.Java:24) 
Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:39) 
Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:25) 
Java.lang.reflect.Method.invoke(Method.Java:597) 
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.Java:399) 
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.Java:262) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:224) 
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.Java:213) 
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.Java:86) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
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:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.Java:123) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
com.opensymphony.xwork2.interceptor.ParametersInterceptor.intercept(ParametersInterceptor.Java:161) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.Java:105) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
org.Apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.Java:83) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
org.Apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.Java:207) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.Java:74) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:219) 
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.Java:218) 
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.Java:455) 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.Java:216) 
com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.Java:127) 

J'ai utilisé hibernate et struts pour créer une application Web et la déployer sur un serveur Linux. Sa fonctionnalité de connexion fonctionnait bien pendant un certain temps, mais après cela, la connexion ne fonctionnait pas et ne présentait pas d'exception dans le fichier journal Tomcat.

12
Atul Thakre

Conformément à la pile d'erreur, votre connexion au serveur MySQL est perdue.

>root cause 

>com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
  No operations allowed after connection closed.
  Connection was implicitly closed due to underlying exception/error: 

** BEGIN NESTED EXCEPTION ** 
    >com.mysql.jdbc.exceptions.jdbc4.CommunicationsException 
MESSAGE: Communications link failure 

>Last packet sent to the server was 43 ms ago. 

>STACKTRACE: 

>com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 

Il est très clair que la cause principale est Communications link failure.

Essayez de faire un ping sur votre serveur de base de données et voyez si vous pouvez vous connecter.
Sinon, résolvez le problème de réseau, puis connectez-vous. Aucune alternative pour cela.

Vous pouvez émettre une ping légère à votre serveur de base de données pour vérifier la disponibilité de la connexion.
Veuillez lire la discussion et les articles suivants:

  1. Ping MySQL Server
  2. Syntaxe Ping et exemple
4
Ravinder Reddy

Il suffit de vérifier une fois si vous avez ajouté @Repository annotation dans la classe Repository. parce que cela pourrait aussi être la raison principale de l'exception.

1
Aditya Bittu