Hello all,
I apologize if this question has already been asked, but I couldn't locate any references to a situation like mine.
I have 2 modules, each has its own HibernateSessionFactory using the same datasource definition (mysql). ModuleA.methodA() calls ModuleB.methodB(). Both ModuleA.methodA() and ModuleB.methodB() have transactional properties declared as PROPAGATION_REQUIRED. Spring, however, fails with :
java.lang.IllegalStateException: Already value [org.springframework.jdbc.datasource.ConnectionHold er@f549de] for key [org.apache.commons.dbcp.BasicDataSource@1c297a3] bound to thread [main]
Looking a little into the spring source code, it appears that new transactions are created or re-used based on their association with the given SessionFactory. In my case I use 2 different SessionFactories with their own sets of DAO definitions, so spring creates a new transaction for the ModuleB.methodB() call. However, after it is done, the TransactionSynchronizationManager is instructed to bind the transaction to the data source and in my case it is the same for both modules. Hence, the exception.
Is my set-up unsupported or unworkable? Any comments.
Thanks,
--Bill


Reply With Quote