0

We're running with Grails 2.5.3 against a MySQL DB and recently introduced a second datasource definition. We're getting the following exceptions in a non-transactional service which is calling into multiple transactional services. The exception occurs when it tries to start the second transaction:

» 3 Aug 2016 16:49:44.119  PooledConnection has already been closed.. Stacktrace follows: 
» 3 Aug 2016 16:49:44.119  java.sql.SQLException: PooledConnection has already been closed. 

It seems like Grails is closing the connection to the second datasource after the first transaction ends and is trying to reuse that connection. I'm wondering if anyone has seen this and/or worked around it.

1 Answers1

0

We had faced the same issue but not for two different datasources. Our application was using Hibernate and iBatis and while the hibernate part was integrated within grails and worked fine, the iBatis code gave the mentioned issue when a second continuous transaction was called.

To solve this we created another datasource in resources.groovy and using the iBatis code with this new datasource. you can refer to Grails Pooled Connection Exception for the configuration details of our solution.

Community
  • 1
  • 1
Maria
  • 21
  • 6
  • However, to note this is just a hack. We are still searching for better solutions. Do let me know if you were able to find something better or narrow down the reason for the issue. – Maria Oct 25 '16 at 09:18