March 2014 began to the unit development of "standardized management network platform", the end of October successfully launched, but there is a bug:
deployment Environment: Apache Tomcat 6.0.41 + mysql5.5 + jbpm
How to Reproduce the bug: after deploying the environment, in the absence of user access to the system, after a night, the next day to log in will report the following error: Could not roll back Hibernate transaction; Nested exception is Org.hibernate.TransactionException:JDBC rollback failed.
* Solution to find primary (surface) article: at the beginning, Baidu, Google "Could not roll back Hibernate transaction; Nested exception is Org.hibernate.TransactionException:JDBC rollback failed. ". Review after the solution found on the Internet, I feel that can not solve my problem.
* Solution Lookup Advanced (in-depth): Find the log of Tomcat, located at:%tomcat_home%\logs\%service_name%-stdout.2015-02-25.log. (Note: The Run-time error log is not found in Stderr.xxx.log; Tomcat automatically starts after restarting the server, registering Tomcat as the service under window)
To view the call stack for the error location:
STACKTRACE:
Com.mysql.jdbc.CommunicationsException:Communications link failure due to underlying exception:
* * BEGIN NESTED EXCEPTION * *
Java.net.SocketException
Message:software caused connection Abort:socket write error
STACKTRACE:
Java.net.SocketException:Software caused connection Abort:socket write error
At Java.net.SocketOutputStream.socketWrite0 (Native Method)
... ... ...
Root cause:
The tomcat server is disconnected from the MySQL database for a period of time without access, and an error occurs:
java.net.socketexception: software caused connection abort: socket write error
Because the connection time-out for MySQL is 8 hours. If you are idle for more than 8 hours, MySQL will automatically disconnect.
Solution:
Use connection pooling to solve this problem, use C3P0 here:
Modify the Hibernate.cfg.xml file
<property name= "Hibernate.connection.provider_class" >org.hibernate.connection.c3p0connectionprovider</ Property>
< property name= "Hibernate.c3p0.min_size" >8</property>
< property name= "Hibernate.c3p0.max_size" >200</property>
< property name= "Hibernate.c3p0.timeout" >600</property>
< property name= "Hibernate.c3p0.max_statements" >0</property>
< property name= "Hibernate.c3p0.idle_test_period" >60</property>
< property name= "Hibernate.c3p0.acquire_increment" >2</property>
< property name= "Hibernate.c3p0.validate" >true</property>
MySQL 8-hour connection timeout time, causing the system to crash overnight, error could not roll back Hibernate transaction