'Pre-bound JDBC Connection found!' exception

Issue

  • We have some custom modules using a common external DataSource.
  • When module A calls module B within a database transaction, following exception is raised:
org.springframework.transaction.IllegalTransactionStateException: Pre-bound JDBC Connection found! HibernateTransactionManager does not support running within DataSourceTransactionManager if told to manage the DataSource itself. It is recommended to use a single HibernateTransactionManager for all transactions on a single DataSource, no matter whether Hibernate or JDBC access.
at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:484)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.startTransaction(AbstractPlatformTransactionManager.java:400)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:373)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.start(DefaultTransactionExecutor.java:139)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:64)
at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:57)
at com.liferay.change.tracking.internal.aop.CTTransactionAdvice.invoke(CTTransactionAdvice.java:80)
at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:57)
at com.liferay.portal.spring.aop.AopInvocationHandler.invoke(AopInvocationHandler.java:49)
.
.
.

 

Environment

  • DXP 7.3

Resolution

  • Liferay DXP uses a unique HibernateTransactionManager, which is configured based on a HibernateSessionFactory and a LiferayDataSource.

  • In this user case, there is an additional external DataSource (different from LiferayDataSource) shared by 'n' modules.

And every module has its own Session Factory and its own Transaction Manager, giving as a result 'n' Transaction Managers sharing a unique DataSource.

Additional Information

 

 

这篇文章有帮助吗?
1 人中有 1 人觉得有帮助