有一个 Grails2.2/Hibernate/Tomcat7/MySQL5.5 网络服务器。在几个小时没有 Web 客户端请求它之后,对它的第一个请求失败如下。(事实上,它每天早上都会发生。)任何顺序请求都会得到正确处理。
我指示 MySQL 驱动程序,?autoReconnect=true
但它没有帮助。
下面可以注意到回滚,但我不直接从我的代码中调用它。相反,它在长时间停顿后尝试持久化对象时隐式发生。
有什么办法可以治愈吗?
Error 500: Executing action [actionName] of controller [MyController] caused exception: Runtime error executing action
Servlet: grails
URI: /appname/grails/appName/actionName.dispatch
Exception Message: Communications link failure during rollback(). Transaction resolution unknown.
Caused by: Communications link failure during rollback(). Transaction resolution unknown.
Class: MyController
At Line: [139]
Code Snippet:
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Communications link failure during rollback(). Transaction resolution unknown.
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1014)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919)
at com.mysql.jdbc.ConnectionImpl.rollback(ConnectionImpl.java:4808)
at org.apache.commons.dbcp.DelegatingConnection.rollback(DelegatingConnection.java:368)
at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.rollback(PoolingDataSource.java:323)
at MyController.logRequest(...)
...
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
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:636)
Tomcat 的 context.xml:
<Resource name="jdbc/JNDI_NAME" auth="Container"
type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/dbname?autoReconnect=true"
username="xxx" password="xxx" maxActive="20" maxIdle="10"
removeAbandoned="true" removeAbandonedTimeout="60" logAbandoned="true"
maxWait="-1"/>