Sunday, February 8, 2015

First Login: HTTP Status 500 - Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException

It appears that MySQL or a firewall is killing off your inactive connections that are hanging around in your jdbc connection pool for long periods of time:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 
The last packet successfully received from the server was 4,665,488 milliseconds ago.

Check the value of wait_timeout on MySQL.

You can play around with DBCP settings e.g. validationQuery, testOnBorrow and testWhileIdle.

A a confuguration that is 'belt and braces', and will probably solve your problem at the expense of performance is:
 
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
  <property name="driverClassName" value="${jdbc.driverClassName}"/>
  <property name="url" value="${jdbc.url}"/>
  <property name="username" value="${jdbc.username}"/>
  <property name="password" value="${jdbc.password}"/>
  <property name="validationQuery" value="SELECT 1"/>
  <property name="testOnBorrow" value="true"/>
</bean>
The above will test connections every time you borrow from the pool.

No comments:

Post a Comment