Uploaded image for project: 'Spring Data MongoDB'
  1. Spring Data MongoDB
  2. DATAMONGO-546

spring-data-mongo 1.0.4: TransactionSyncManager in spring throws exception

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.4
    • Fix Version/s: 1.1 GA
    • Component/s: Core
    • Labels:
      None

      Description

      When I migrated to spring-data-mongo 1.0.4 from 1.0.2 I faced following stacktrace
      2012-10-04 09:58:32,966 ERROR o.s.t.s.TransactionSynchronizationUtils - TransactionSynchronization.beforeCompletion threw exception
      java.lang.IllegalStateException: No value for key [Mongo: localhost:27017] bound to thread [[email protected]]
      at org.springframework.transaction.support.TransactionSynchronizationManager.unbindResource(TransactionSynchronizationManager.java:209) ~[spring-tx-3.1.1.RELEASE.jar:3.1.1.RELEASE]
      at org.springframework.transaction.support.ResourceHolderSynchronization.beforeCompletion(ResourceHolderSynchronization.java:69) ~[spring-tx-3.1.1.RELEASE.jar:3.1.1.RELEASE]
      at org.springframework.transaction.support.TransactionSynchronizationUtils.triggerBeforeCompletion(TransactionSynchronizationUtils.java:106) ~[spring-tx-3.1.1.RELEASE.jar:3.1.1.RELEASE]
      at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerBeforeCompletion(AbstractPlatformTransactionManager.java:937) [spring-tx-3.1.1.RELEASE.jar:3.1.1.RELEASE]
      at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:738) [spring-tx-3.1.1.RELEASE.jar:3.1.1.RELEASE]
      at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723) [spring-tx-3.1.1.RELEASE.jar:3.1.1.RELEASE]
      at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393) [spring-tx-3.1.1.RELEASE.jar:3.1.1.RELEASE]

      As result I can't work with mongo at all

      My mongo config is:
      <context:component-scan base-package="com.some.repository.mongo" />

      <mongo:repositories base-package="com.some.domain.mongo" />

      <mongo:db-factory dbname="content_documents" host="localhost" port="27017"/>

      <mongo:mapping-converter>
      <mongo:custom-converters>
      <mongo:converter>
      <bean class="com.some.OutlineWriteConverter"/>
      </mongo:converter>
      <mongo:converter>
      <bean class="com.some.OutlineReadConverter"/>
      </mongo:converter>
      </mongo:custom-converters>
      </mongo:mapping-converter>

      <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
      <constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/>
      <constructor-arg name="mongoConverter" ref="mappingConverter" />
      </bean>
      And transaction configured as:
      <aop:aspectj-autoproxy />

      <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
      <property name="dataSource" ref="dataSource" />
      </bean>

      <tx:advice id="txAdvice" transaction-manager="transactionManager">
      <tx:attributes>
      <tx:method name="*" propagation="REQUIRED" isolation="READ_COMMITTED" rollback-for="java.lang.RuntimeException"/>
      </tx:attributes>
      </tx:advice>

      <aop:config proxy-target-class="true">
      <aop:pointcut id="transactionServiceOperation"
      expression="execution(* com.some..service..Service.(..)) || @annotation(org.springframework.transaction.annotation.Transactional)" />
      <aop:advisor pointcut-ref="transactionServiceOperation" advice-ref="txAdvice" />
      </aop:config>

        Activity

        Hide
        sergiov Sergio added a comment -

        Sorry little mistake - I can work with Mongo and this exception seems not to influence work at all, but it is still confusing and ugly

        Show
        sergiov Sergio added a comment - Sorry little mistake - I can work with Mongo and this exception seems not to influence work at all, but it is still confusing and ugly
        Hide
        sergiov Sergio added a comment -

        Seems it happens when multiple transactions are sequentially called. First TransactionSynchronizedManager.unbindResource called successfully without error, further calls issue exception because resource is already unbound

        Show
        sergiov Sergio added a comment - Seems it happens when multiple transactions are sequentially called. First TransactionSynchronizedManager.unbindResource called successfully without error, further calls issue exception because resource is already unbound
        Hide
        anztenney BJ Tenney added a comment -

        We're getting this in our application when we move to 1.0.4. If I move back to 1.0.2 then this problem does not occur. However, unlike for Sergio, this is blocking the application from executing properly. I'm going through several transactional services, but my mongo repository is not marked transactional. I have not tried 1.1 yet

        Show
        anztenney BJ Tenney added a comment - We're getting this in our application when we move to 1.0.4. If I move back to 1.0.2 then this problem does not occur. However, unlike for Sergio, this is blocking the application from executing properly. I'm going through several transactional services, but my mongo repository is not marked transactional. I have not tried 1.1 yet
        Hide
        dbryant_uk Daniel Bryant added a comment -

        I'm getting this in 1.0.4 as well. I can't see any obvious side-effects with the data I am attempting to persist (i.e. all entities appear to save correctly). However, this make Exception appear many times in the logs (once for every Mongo save?) and in addition to making the logs look ugly it also makes me a bit nervous!

        Show
        dbryant_uk Daniel Bryant added a comment - I'm getting this in 1.0.4 as well. I can't see any obvious side-effects with the data I am attempting to persist (i.e. all entities appear to save correctly). However, this make Exception appear many times in the logs (once for every Mongo save?) and in addition to making the logs look ugly it also makes me a bit nervous!
        Hide
        dizzy George Niculae added a comment -

        It could be related to the patch I submitted for https://jira.springsource.org/browse/DATAMONGO-464
        Will check if this is the case

        Show
        dizzy George Niculae added a comment - It could be related to the patch I submitted for https://jira.springsource.org/browse/DATAMONGO-464 Will check if this is the case
        Hide
        dbryant_uk Daniel Bryant added a comment -

        Just a quick update - this Exception doesn't appear for me now that I have switched my Maven spring-data-mongodb dependency to version 1.1.0.RELEASE.

        Show
        dbryant_uk Daniel Bryant added a comment - Just a quick update - this Exception doesn't appear for me now that I have switched my Maven spring-data-mongodb dependency to version 1.1.0.RELEASE.
        Hide
        anztenney BJ Tenney added a comment -

        I also upgraded to 1.1.0.RELEASE and am no longer seeing the issue

        Show
        anztenney BJ Tenney added a comment - I also upgraded to 1.1.0.RELEASE and am no longer seeing the issue

          People

          • Assignee:
            olivergierke Oliver Gierke
            Reporter:
            sergiov Sergio
            Last updater:
            Trevor Marshall
          • Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: