I have a full operating Spring MVC Application running with Spring Security but I get the following error whenever the server hasn't been active in a while and someone tries to login:
HTTP Status 500 - Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.TransactionException: JDBC begin transaction failed
Sometimes after (approximately 5 seconds later) it starts to work normally.
I searched and found this link but I don't know how to configure connection testing in the connection pool configuration.
Any advice?
EDIT:
I found this link to set the configuration pool, so I tried to implement it in my dataSource
:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"><property name="driverClassName" value="com.mysql.jdbc.Driver" /><property name="url" value="jdbc:mysql://192.168.254.45:3306/7jogos" /><property name="password" value="..." /><property name="username" value="..." /><!-- Configuration pool --><property name="validationQuery" value="SELECT 1" /><property name="validationInterval" value="34000" /><property name="testOnBorrow" value="true" /><property name="removeAbandoned" value="true" /><property name="removeAbandonedTimeout" value="55" /></bean>
But I end up getting an error on validationInterval
saying:
Multiple annotations found at this line: - No setter found for property 'validationInterval' in class 'org.apache.commons.dbcp.BasicDataSource'