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>

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: