我有一个使用Hibernate和tomcat server.my应用程序的java应用程序正常工作几个小时。然后停止工作..显示以下错误。我不知道发生了什么,我对hibernate技术来说真的很新。我读了关于c3p0 lib的一些内容,但我不知道如何工作..
HTTP Status 500 - JDBC rollback failed
type Exception report
message JDBC rollback failed
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.hibernate.TransactionException: JDBC rollback failed
org.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:200)
com.javawebtutor.service.LoginService.getUserByUserId(LoginService.java:37)
com.javawebtutor.service.LoginService.authenticateUser(LoginService.java:17)
com.javawebtutor.controller.LoginServlet.doPost(LoginServlet.java:33)
javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance(Constructor.java:423)
com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
com.mysql.jdbc.Util.getInstance(Util.java:386)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1013)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
com.mysql.jdbc.ConnectionImpl.throwConnectionClosedException(ConnectionImpl.java:1251)
com.mysql.jdbc.ConnectionImpl.checkClosed(ConnectionImpl.java:1243)
com.mysql.jdbc.ConnectionImpl.rollback(ConnectionImpl.java:4723)
org.hibernate.transaction.JDBCTransaction.rollbackAndResetAutoCommit(JDBCTransaction.java:213)
org.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:192)
com.javawebtutor.service.LoginService.getUserByUserId(LoginService.java:37)
com.javawebtutor.service.LoginService.authenticateUser(LoginService.java:17)
com.javawebtutor.controller.LoginServlet.doPost(LoginServlet.java:33)
javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 33,669,634 milliseconds ago. The last packet sent successfully to the server was 6 milliseconds ago.
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance(Constructor.java:423)
com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3589)
com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3478)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4019)
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490)
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2683)
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2144)
com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2310)
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)
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.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:890)
com.javawebtutor.service.LoginService.getUserByUserId(LoginService.java:33)
com.javawebtutor.service.LoginService.authenticateUser(LoginService.java:17)
com.javawebtutor.controller.LoginServlet.doPost(LoginServlet.java:33)
javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
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:3039)
com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3489)
com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3478)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4019)
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490)
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2683)
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2144)
com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2310)
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)
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.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:890)
com.javawebtutor.service.LoginService.getUserByUserId(LoginService.java:33)
com.javawebtutor.service.LoginService.authenticateUser(LoginService.java:17)
com.javawebtutor.controller.LoginServlet.doPost(LoginServlet.java:33)
javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.50 logs.
Apache Tomcat/8.0.50
我的hibernate.cfg.xml是
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/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/dbname?UseUnicode=true&characterEncoding=utf8
</property>
<property name="hibernate.connection.username">dbusername</property>
<property name="hibernate.connection.password">dbpass</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">update</property>
<mapping class="com.javawebtutor.model.User" />
<mapping class="com.javawebtutor.model.Questionaire" />
</session-factory>
</hibernate-configuration>
请帮助..