启动没错误,但是当你进入页面的时候经常出现以下错误,但是你刷新页面就好了,过几分钟再点页面上其他链接又出现以下错误,不知道怎么回事在tomcat上报这种错误,不知道是什么原因,用本地数据库没问题,用新网J500虚拟主机的时候出现这种错误,搞了几天都没搞好,不知道问题出在哪...Struts Problem ReportStruts has detected an unhandled exception:Messages:
Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
Communications link failure The last packet successfully received from the server was 1,618,761 milliseconds ago. The last packet sent successfully to the server was 22 milliseconds ago.
could not execute query
could not execute query; nested exception is org.hibernate.exception.JDBCConnectionException: could not execute query
File: com/mysql/jdbc/MysqlIO.java
Line number: 2,540
org.springframework.dao.DataAccessResourceFailureException: could not execute query; nested exception is org.hibernate.exception.JDBCConnectionException: could not execute query
    org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:627)
    org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
    org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)
    org.springframework.orm.hibernate3.HibernateTemplate.executeFind(HibernateTemplate.java:343)
    org.gary.core.factories.impl.BasicDaoFactoryImpl.list(BasicDaoFactoryImpl.java:111)
    org.gary.core.factories.impl.BasicServiceFactoryImpl.list(BasicServiceFactoryImpl.java:66)
    org.gary.product.service.impl.ProductServiceImpl.getProductList(ProductServiceImpl.java:79)
    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:585)
    org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
    org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    $Proxy20.getProductList(Unknown Source)
org.hibernate.exception.JDBCConnectionException: could not execute query
    org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:99)
    org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    org.hibernate.loader.Loader.doList(Loader.java:2536)
    org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
    org.hibernate.loader.Loader.list(Loader.java:2271)
    org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:452)
    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:1268)
    org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
    org.gary.core.factories.impl.BasicDaoFactoryImpl$4.doInHibernate(BasicDaoFactoryImpl.java:118)
    org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
    org.springframework.orm.hibernate3.HibernateTemplate.executeFind(HibernateTemplate.java:343)
    org.gary.core.factories.impl.BasicDaoFactoryImpl.list(BasicDaoFactoryImpl.java:111)
    org.gary.core.factories.impl.BasicServiceFactoryImpl.list(BasicServiceFactoryImpl.java:66)
com.mysql.jdbc.CommunicationsException: Communications link failure The last packet successfully received from the server was 1,618,761 milliseconds ago. The last packet sent successfully to the server was 22 milliseconds ago.
    com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1112)
    com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3090)
    com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2979)
    com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3520)
    com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990)
    com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151)
    com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2625)
    com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
    com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2281)
    org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
    org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
    org.hibernate.loader.Loader.getResultSet(Loader.java:1953)
java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
    com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2540)
    com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2990)
    com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2979)
    com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3520)
    com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990)
    com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151)
    com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2625)
    com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
    com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2281)
    org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
    org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
    org.hibernate.loader.Loader.getResultSet(Loader.java:1953)
    org.hibernate.loader.Loader.doQuery(Loader.java:802)
    org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
    org.hibernate.loader.Loader.doList(Loader.java:2533)
    org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
    org.hibernate.loader.Loader.list(Loader.java:2271)

解决方案 »

  1.   

    我连项目怎么传,tomcat怎么用都还没搞清楚呢,就一个www目录什么都没有了,还说什么独享tomcat,楼上是怎么弄的?
      

  2.   

    1. 有可能MySQL 的默认设置中,空闲超过 8 小时的连接会被自动关闭(interactive_timeout=28800,wait_timeout=28800)。
    当连接池没有销毁掉空闲时间超过设置的连接,这些连接会因为已被数据库关闭而导致失效。
    2. 有可能驱动版本有问题。看看下列说明:
    1. http://www.dangkai.com/ArticlePage/Article30149.htm2. http://hi.baidu.com/mengle131/blog/item/9d8de7b464f62d768ad4b27c.html