java.lang.IllegalStateException: Already value [org.springframework.jdbc.datasource.ConnectionHolder@14e9851] for key [org.apache.commons.dbcp.BasicDataSource@4dd1b] bound to thread [main]

Spring JIRA | Bob Johnson | 1 decade ago
  1. 0

    There appears to be a problem with release 1.1. I have a declarative transaction management configuration that works correctly in release 1.0.2, but crashes using release 1.1! The exception I am getting is: ------------------------------------------------ Could not create Hibernate transaction; nested exception is java.lang.IllegalStateException: Already value [org.springframework.jdbc.datasource.ConnectionHolder@14e9851] for key [org.apache.commons.dbcp.BasicDataSource@4dd1b] bound to thread [main] ------------------------------------------------ This exception appears as soon as I introduce a TransactionProxyFactoryBean for a POJO class (see applicationContext.xml snippet below). This exception is discussed in SPR-272 which discusses patches to release 1.1 RC2. I have verified that release 1.1 does indeed contain these patches in the source. Is it possible that these patches are somehow related to the failure I am experiencing in 1.1 ??? NOTE: The POJO ("JobService") is a simple delegate that dispatches to an underlying DAO. I have the following bean definitions (among others): ------------------------------------------------------------------------------------- <beans> <bean id="flipperDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName"> <value>oracle.jdbc.driver.OracleDriver</value> </property> <property name="url"> <value>jdbc:oracle:thin:@XEM02DEV:1527:XEM02DEV</value> </property> <property name="username"> <value>******</value> </property> <property name="password"> <value>*********</value> </property> <property name="defaultAutoCommit"> <value>false</value> </property> </bean> <bean id="flipperSessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean"> <property name="dataSource"><ref bean="flipperDataSource"/></property> <property name="mappingResources"> <list> <value>conf/hibernate/JobDto.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">net.sf.hibernate.dialect.Oracle9Dialect</prop> <!--<prop key="hibernate.show_sql">false</prop>--> </props> </property> </bean> <bean id="xactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager"> <property name="sessionFactory"> <ref bean="flipperSessionFactory"/> </property> </bean> <bean id="JobDaoTarget" class="com.xcel.flipper.persist.dao.hibernate.HibernateJobDao"> <property name="sessionFactory"> <ref bean="flipperSessionFactory"/> </property> </bean> <bean id="JobService" class="com.xcel.flipper.persist.dao.JobService"> <property name="jobDao"> <ref bean="JobDaoTarget"/> </property> </bean> <!-- Transactional Proxy --> <bean id="JobDao" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager"><ref local="xactionManager"/></property> <property name="target"><ref bean="JobService"/></property> <property name="transactionAttributes"> <props> <prop key="*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> </beans> ----------------------------------------------------------------------------- When I added the Transactional Proxy (TransactionProxyFactoryBean show above), the unit test for a class using the JobDoa fails with the following error: ----------------------------------------------------------------------------- Testsuite: com.xcel.flipper.persist.dao.ActivityExecutionLogDaoTest Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 7.187 sec Testcase: testActivityExectionLogCLOBField(com.xcel.flipper.persist.dao.ActivityExecutionLogDaoTest): Caused an ERROR Could not create Hibernate transaction; nested exception is java.lang.IllegalStateException: Already value [org.springframework.jdbc.datasource.ConnectionHolder@14e9851] for key [org.apache.commons.dbcp.BasicDataSource@4dd1b] bound to thread [main] org.springframework.transaction.CannotCreateTransactionException: Could not create Hibernate transaction; nested exception is java.lang.IllegalStateException: Already value [org.springframework.jdbc.datasource.ConnectionHolder@14e9851] for key [org.apache.commons.dbcp.BasicDataSource@4dd1b] bound to thread [main] java.lang.IllegalStateException: Already value [org.springframework.jdbc.datasource.ConnectionHolder@14e9851] for key [org.apache.commons.dbcp.BasicDataSource@4dd1b] bound to thread [main] at org.springframework.transaction.support.TransactionSynchronizationManager.bindResource(TransactionSynchronizationManager.java:137) at org.springframework.orm.hibernate.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:412) at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:269) at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:200) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:49) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:152) at $Proxy0.create(Unknown Source) at com.xcel.flipper.persist.dao.ActivityExecutionLogTestService.createJob(ActivityExecutionLogTestService.java:84) at com.xcel.flipper.persist.dao.ActivityExecutionLogTestService.initialize(ActivityExecutionLogTestService.java:55) at com.xcel.flipper.persist.dao.ActivityExecutionLogTestService.runTest(ActivityExecutionLogTestService.java:139) at com.xcel.flipper.persist.dao.ActivityExecutionLogTestService$$FastClassByCGLIB$$73e1c0c5.invoke(<generated>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.springframework.aop.framework.Cglib2AopProxy$MethodInvocationImpl.invokeJoinpoint(Cglib2AopProxy.java:878) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:116) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:56) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:596) at com.xcel.flipper.persist.dao.ActivityExecutionLogTestService$$EnhancerByCGLIB$$35ec6769.runTest(<generated>) at com.xcel.flipper.persist.dao.ActivityExecutionLogDaoTest.testActivityExectionLogCLOBField(ActivityExecutionLogDaoTest.java:63) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at org.apache.commons.jelly.tags.ant.AntTag.doTag(AntTag.java:232) .......... -----------------------------------------------------------------------------

    Spring JIRA | 1 decade ago | Bob Johnson
    java.lang.IllegalStateException: Already value [org.springframework.jdbc.datasource.ConnectionHolder@14e9851] for key [org.apache.commons.dbcp.BasicDataSource@4dd1b] bound to thread [main]
  2. 0

    There appears to be a problem with release 1.1. I have a declarative transaction management configuration that works correctly in release 1.0.2, but crashes using release 1.1! The exception I am getting is: ------------------------------------------------ Could not create Hibernate transaction; nested exception is java.lang.IllegalStateException: Already value [org.springframework.jdbc.datasource.ConnectionHolder@14e9851] for key [org.apache.commons.dbcp.BasicDataSource@4dd1b] bound to thread [main] ------------------------------------------------ This exception appears as soon as I introduce a TransactionProxyFactoryBean for a POJO class (see applicationContext.xml snippet below). This exception is discussed in SPR-272 which discusses patches to release 1.1 RC2. I have verified that release 1.1 does indeed contain these patches in the source. Is it possible that these patches are somehow related to the failure I am experiencing in 1.1 ??? NOTE: The POJO ("JobService") is a simple delegate that dispatches to an underlying DAO. I have the following bean definitions (among others): ------------------------------------------------------------------------------------- <beans> <bean id="flipperDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName"> <value>oracle.jdbc.driver.OracleDriver</value> </property> <property name="url"> <value>jdbc:oracle:thin:@XEM02DEV:1527:XEM02DEV</value> </property> <property name="username"> <value>******</value> </property> <property name="password"> <value>*********</value> </property> <property name="defaultAutoCommit"> <value>false</value> </property> </bean> <bean id="flipperSessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean"> <property name="dataSource"><ref bean="flipperDataSource"/></property> <property name="mappingResources"> <list> <value>conf/hibernate/JobDto.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">net.sf.hibernate.dialect.Oracle9Dialect</prop> <!--<prop key="hibernate.show_sql">false</prop>--> </props> </property> </bean> <bean id="xactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager"> <property name="sessionFactory"> <ref bean="flipperSessionFactory"/> </property> </bean> <bean id="JobDaoTarget" class="com.xcel.flipper.persist.dao.hibernate.HibernateJobDao"> <property name="sessionFactory"> <ref bean="flipperSessionFactory"/> </property> </bean> <bean id="JobService" class="com.xcel.flipper.persist.dao.JobService"> <property name="jobDao"> <ref bean="JobDaoTarget"/> </property> </bean> <!-- Transactional Proxy --> <bean id="JobDao" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager"><ref local="xactionManager"/></property> <property name="target"><ref bean="JobService"/></property> <property name="transactionAttributes"> <props> <prop key="*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> </beans> ----------------------------------------------------------------------------- When I added the Transactional Proxy (TransactionProxyFactoryBean show above), the unit test for a class using the JobDoa fails with the following error: ----------------------------------------------------------------------------- Testsuite: com.xcel.flipper.persist.dao.ActivityExecutionLogDaoTest Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 7.187 sec Testcase: testActivityExectionLogCLOBField(com.xcel.flipper.persist.dao.ActivityExecutionLogDaoTest): Caused an ERROR Could not create Hibernate transaction; nested exception is java.lang.IllegalStateException: Already value [org.springframework.jdbc.datasource.ConnectionHolder@14e9851] for key [org.apache.commons.dbcp.BasicDataSource@4dd1b] bound to thread [main] org.springframework.transaction.CannotCreateTransactionException: Could not create Hibernate transaction; nested exception is java.lang.IllegalStateException: Already value [org.springframework.jdbc.datasource.ConnectionHolder@14e9851] for key [org.apache.commons.dbcp.BasicDataSource@4dd1b] bound to thread [main] java.lang.IllegalStateException: Already value [org.springframework.jdbc.datasource.ConnectionHolder@14e9851] for key [org.apache.commons.dbcp.BasicDataSource@4dd1b] bound to thread [main] at org.springframework.transaction.support.TransactionSynchronizationManager.bindResource(TransactionSynchronizationManager.java:137) at org.springframework.orm.hibernate.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:412) at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:269) at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:200) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:49) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:152) at $Proxy0.create(Unknown Source) at com.xcel.flipper.persist.dao.ActivityExecutionLogTestService.createJob(ActivityExecutionLogTestService.java:84) at com.xcel.flipper.persist.dao.ActivityExecutionLogTestService.initialize(ActivityExecutionLogTestService.java:55) at com.xcel.flipper.persist.dao.ActivityExecutionLogTestService.runTest(ActivityExecutionLogTestService.java:139) at com.xcel.flipper.persist.dao.ActivityExecutionLogTestService$$FastClassByCGLIB$$73e1c0c5.invoke(<generated>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.springframework.aop.framework.Cglib2AopProxy$MethodInvocationImpl.invokeJoinpoint(Cglib2AopProxy.java:878) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:116) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:56) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:596) at com.xcel.flipper.persist.dao.ActivityExecutionLogTestService$$EnhancerByCGLIB$$35ec6769.runTest(<generated>) at com.xcel.flipper.persist.dao.ActivityExecutionLogDaoTest.testActivityExectionLogCLOBField(ActivityExecutionLogDaoTest.java:63) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at org.apache.commons.jelly.tags.ant.AntTag.doTag(AntTag.java:232) .......... -----------------------------------------------------------------------------

    Spring JIRA | 1 decade ago | Bob Johnson
    java.lang.IllegalStateException: Already value [org.springframework.jdbc.datasource.ConnectionHolder@14e9851] for key [org.apache.commons.dbcp.BasicDataSource@4dd1b] bound to thread [main]
  3. 0

    [SPR-333] Already value for key bound to thread - Spring JIRA

    spring.io | 1 year ago
    java.lang.IllegalStateException: Already value for key bound to thread
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Spring & Hibernate: can not bind session.

    Stack Overflow | 4 years ago | Prevail
    java.lang.IllegalStateException: Already value [org.springframework.orm.hibernate3.SessionHolder@4cccafeb] for key [org.hibernate.impl.SessionFactoryImpl@1457e272] bound to thread [http-0.0.0.0-8443-35]
  6. 0

    nested transactionTemplate

    Stack Overflow | 4 years ago | Jin Kim
    java.lang.IllegalStateException: Already value [org.springframework.jdbc.datasource.ConnectionHolder@e4b2ed] for key [org.apache.tomcat.dbcp.dbcp.BasicDataSource@26cc37d2] bound to thread [http-bio-8084-exec-13]

    4 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalStateException

      Already value [org.springframework.jdbc.datasource.ConnectionHolder@14e9851] for key [org.apache.commons.dbcp.BasicDataSource@4dd1b] bound to thread [main]

      at org.springframework.transaction.support.TransactionSynchronizationManager.bindResource()
    2. Spring Tx
      TransactionSynchronizationManager.bindResource
      1. org.springframework.transaction.support.TransactionSynchronizationManager.bindResource(TransactionSynchronizationManager.java:137)
      1 frame
    3. Hibernate
      HibernateTransactionManager.doBegin
      1. org.springframework.orm.hibernate.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:412)
      1 frame
    4. Spring Tx
      TransactionInterceptor.invoke
      1. org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:269)
      2. org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:200)
      3. org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:49)
      3 frames
    5. Spring AOP
      JdkDynamicAopProxy.invoke
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138)
      2. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:152)
      2 frames
    6. Unknown
      $Proxy0.create
      1. $Proxy0.create(Unknown Source)
      1 frame
    7. com.xcel.flipper
      ActivityExecutionLogTestService$$FastClassByCGLIB$$73e1c0c5.invoke
      1. com.xcel.flipper.persist.dao.ActivityExecutionLogTestService.createJob(ActivityExecutionLogTestService.java:84)
      2. com.xcel.flipper.persist.dao.ActivityExecutionLogTestService.initialize(ActivityExecutionLogTestService.java:55)
      3. com.xcel.flipper.persist.dao.ActivityExecutionLogTestService.runTest(ActivityExecutionLogTestService.java:139)
      4. com.xcel.flipper.persist.dao.ActivityExecutionLogTestService$$FastClassByCGLIB$$73e1c0c5.invoke(<generated>)
      4 frames
    8. IDEA
      MethodProxy.invoke
      1. net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
      1 frame
    9. Spring AOP
      ReflectiveMethodInvocation.proceed
      1. org.springframework.aop.framework.Cglib2AopProxy$MethodInvocationImpl.invokeJoinpoint(Cglib2AopProxy.java:878)
      2. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:116)
      2 frames
    10. Spring Tx
      TransactionInterceptor.invoke
      1. org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:56)
      1 frame
    11. Spring AOP
      Cglib2AopProxy$DynamicAdvisedInterceptor.intercept
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138)
      2. org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:596)
      2 frames
    12. com.xcel.flipper
      ActivityExecutionLogDaoTest.testActivityExectionLogCLOBField
      1. com.xcel.flipper.persist.dao.ActivityExecutionLogTestService$$EnhancerByCGLIB$$35ec6769.runTest(<generated>)
      2. com.xcel.flipper.persist.dao.ActivityExecutionLogDaoTest.testActivityExectionLogCLOBField(ActivityExecutionLogDaoTest.java:63)
      2 frames
    13. Java RT
      DelegatingMethodAccessorImpl.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      3 frames
    14. commons-jelly-tags-antlr
      AntTag.doTag
      1. org.apache.commons.jelly.tags.ant.AntTag.doTag(AntTag.java:232)
      1 frame