So this has been discussed a million times, sometimes people have found issues with their transaction , sometimes they have had made a mistake of using both HibernateTransactionManager with DataSourceTRansactionManger..and sometimes have used same transaction against two datasources! Before I posted this up here...I made sure we aren't doing any of those obvious mistakes.
By the way this is whatI am talking about :
We notice running into this issue after we find this in our Weblogic logs :Code: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:426) at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:350) at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:262) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:102) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy207.getMyPersonalData(Unknown Source)
So we know this comes from the following code in Spring :Code:<1359911323638> <BEA-001153> <Forcibly releasing inactive connection "weblogic.jdbc.wrapper.PoolConnection_oracle_jdbc_driver_T4CConnection@1c59665" back into the connection pool "my_Pool", currently reserved by: java.lang.Exception at weblogic.jdbc.common.internal.ConnectionEnv.setup(ConnectionEnv.java:308) at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:314) at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:292) at weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:425) at weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:316) at weblogic.jdbc.common.internal.ConnectionPoolManager.reserve(ConnectionPoolManager.java:93) at weblogic.jdbc.common.internal.ConnectionPoolManager.reserve(ConnectionPoolManager.java:106) at weblogic.jdbc.pool.Driver.connect(Driver.java:149) at weblogic.jdbc.jts.Driver.getNonTxConnection(Driver.java:642) at weblogic.jdbc.jts.Driver.connect(Driver.java:124) at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:338) at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:81) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:421) at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144) at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1538) at org.hibernate.loader.Loader.doQuery(Loader.java:661) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) at org.hibernate.loader.Loader.loadEntity(Loader.java:1851) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42) at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3038) at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395) at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:98) at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878) at org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:836) at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:66) at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111) at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:140) at com.business.bom.MYJob$$EnhancerByCGLIB$$36de44fa.getStartedTime(<generated>) at ... blha blha com.my.apps.ui.publishedReport.MyPublishedReportController.getMyJobView(MyPublishedReportController.java:231) at at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:857) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:792) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:475) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:430) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
Well after immense google searching i have still not been able to recreate this issue or know the cause of this issue...Code:tx.getDataSource != null and ! tx.getDataSource.issynchronisedwithTransaction { throw this prebound jdbc connection found!..... }
My suspicion is
1)Weblogic is taking away the connection before a transaction is completed and that releases the transaction but it does not give hibernate and spring a chance to do its cleanup process and hence never set the isSyncrnoized with transaction as false (Not sure how to recreate to validate this suspiscion)
2) We have a PROPOGATION_REQUIRED even for get* methods....They are not PROPOGATION_REQUIRED,read-only
3) We have the hibernateTransaction injected at the DAO as well as the Service layer..
Any good soul has suggestion on what my app is doing wrong?
* This issue never happens in our development environment. Happens only in production! Also once we recycle the cluster insatnce it goes away for few days, but only to come back.


Reply With Quote