Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not roll back JPA transaction; javax.persistence.PersistenceException: unexpected error when rollbacking" exceptions?

What events cause "org.springframework.transaction.TransactionSystemException - Could not roll back JPA transaction; nested exception is javax.persistence.PersistenceException: unexpected error when rollbacking" exceptions?

like image 214
user3097459 Avatar asked Dec 12 '13 23:12

user3097459


1 Answers

I got the same error with spring and Jpa. The problem was with disconnection to Mysql database in case of timeout. I didn't use application during the night and in the morning I got the same error. When you inactive, spring do nothing and it get timeout. To prevent it you can add into application.properties next lines:

spring.datasource.connection-test-query="SELECT 1"
spring.datasource.test-while-idle=true
spring.datasource.test-on-borrow=true

Now it works fine. Also additional info from Virtustilus blog can be useful.

like image 188
virtustilus Avatar answered Nov 14 '22 15:11

virtustilus