org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.transaction.PlatformTransactionManager] is defined: expected single matching bean but found 18: transactionManagerSite-39,transactionManagerSite-18,transactionManagerSite-19,transactionManagerSite-34,transactionManagerSite-25,transactionManagerSite-36,transactionManagerSite-1,transactionManagerSite-10,transactionManagerSite-21,transactionManagerSite-32,transactionManagerSite-2,transactionManagerSite-11,transactionManagerSite-22,transactionManagerSite-33,transactionManagerSite-3,transactionManagerSite-4,transactionManagerSite-40,transactionManagerSite-8

Spring JIRA | Franz Neumann | 3 months ago
  1. 0

    Hi, my project consists of 18 almost equialent jpa outbound channer adapter. That's an example of one of it: {code} <bean id="dataSourceSite-1" parent="baseDataSource"> <property name="jdbcUrl" value="${site.1.jdbcUrl}" /> <property name="user" value="${site.1.user}" /> <property name="password" value="${site.1.password}" /> <property name="dataSourceName" value="site1"/> <!-- initialPoolSize = minPoolSize --> <property name="initialPoolSize" value="${site.1.minPoolSize}"/> <property name="minPoolSize" value="${site.1.minPoolSize}" /> <property name="maxPoolSize" value="${site.1.maxPoolSize}" /> <property name="acquireIncrement" value="${site.1.acquireIncrement}" /> </bean> <bean id="emfSite-1" parent="baseEntityManagerFactory"> <property name="dataSource" ref="dataSourceSite-1"/> <property name="persistenceUnitName" value="emfSite-1"/> </bean> <bean id="transactionManagerSite-1" class="org.springframework.orm.jpa.JpaTransactionManager"> <constructor-arg ref="emfSite-1"/> </bean> <int-jpa:outbound-channel-adapter id="jpaOutboundChannelSite-1" persist-mode="MERGE" flush="true" entity-manager-factory="emfSite-1"> <int-jpa:request-handler-advice-chain> <ref bean="someFailureAdvice"/> <tx:advice transaction-manager="transactionManagerSite-1"> <tx:attributes> <tx:method name="*" timeout="60" rollback-for="com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException"/> </tx:attributes> </tx:advice> </int-jpa:request-handler-advice-chain> </int-jpa:outbound-channel-adapter> {code} I've updated my project to spring core 4.3.1->4.3.2 (spring integration has been still 4.3.1) and get now such exception: {code} org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.transaction.PlatformTransactionManager] is defined: expected single matching bean but found 18: transactionManagerSite-39,transactionManagerSite-18,transactionManagerSite-19,transactionManagerSite-34,transactionManagerSite-25,transactionManagerSite-36,transactionManagerSite-1,transactionManagerSite-10,transactionManagerSite-21,transactionManagerSite-32,transactionManagerSite-2,transactionManagerSite-11,transactionManagerSite-22,transactionManagerSite-33,transactionManagerSite-3,transactionManagerSite-4,transactionManagerSite-40,transactionManagerSite-8 at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:368) ~[DefaultListableBeanFactory.class:4.3.2.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:334) ~[DefaultListableBeanFactory.class:4.3.2.RELEASE] at org.springframework.transaction.interceptor.TransactionAspectSupport.determineTransactionManager(TransactionAspectSupport.java:366) ~[TransactionAspectSupport.class:4.3.2.RELEASE] at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:270) ~[TransactionAspectSupport.class:4.3.2.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[TransactionInterceptor.class:4.3.2.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [ReflectiveMethodInvocation.class:4.3.2.RELEASE] at org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice$1.execute(AbstractRequestHandlerAdvice.java:75) ~[AbstractRequestHandlerAdvice$1.class:4.3.1.RELEASE] at mypackagewebapp.spring.integration.ExportHandlerAdvice.doInvoke(ExportHandlerAdvice.java:69) ~[ExportHandlerAdvice.class:na] at org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice.invoke(AbstractRequestHandlerAdvice.java:70) [AbstractRequestHandlerAdvice.class:4.3.1.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [ReflectiveMethodInvocation.class:4.3.2.RELEASE] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) [JdkDynamicAopProxy.class:4.3.2.RELEASE] at com.sun.proxy.$Proxy34.handleRequestMessage(Unknown Source) [na:na] {code} As a consequence the project can't export data to Mysql. With spring-core 4.3.1 it did work. Are you aware about the problem for the next release?

    Spring JIRA | 3 months ago | Franz Neumann
    org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.transaction.PlatformTransactionManager] is defined: expected single matching bean but found 18: transactionManagerSite-39,transactionManagerSite-18,transactionManagerSite-19,transactionManagerSite-34,transactionManagerSite-25,transactionManagerSite-36,transactionManagerSite-1,transactionManagerSite-10,transactionManagerSite-21,transactionManagerSite-32,transactionManagerSite-2,transactionManagerSite-11,transactionManagerSite-22,transactionManagerSite-33,transactionManagerSite-3,transactionManagerSite-4,transactionManagerSite-40,transactionManagerSite-8
  2. 0

    Multiple DB/Transaction Manager and No Unique bean exception upgrading to spring 1.2.1

    GitHub | 2 years ago | leninayya
    org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.transaction.PlatformTransactionManager] is defined: expected single matching bean but found 4: aTransaction,bTransaction,transactionManager,cTransaction
  3. 0

    Multiple TxManager working in spring boot 1.1.9 broken when trying to upgrade to boot 1.2.1 with spring framework 4.1.X(1,2,3,4)

    Stack Overflow | 2 years ago | user2232870
    org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.transaction.PlatformTransactionManager] is defined: expected single matching bean but found 4: aTransaction,bTransaction,transactionManager,cTransaction
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    No qualifying bean of type [org.springframework.transaction.PlatformTransactionManager] is defined

    Stack Overflow | 1 year ago | Jay113
    org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.transaction.PlatformTransactionManager] is defined: expected single matching bean but found 2: transactionManagerLegacy,transactionManager
  6. 0

    AbstractTransactionalTestNGSpringContextTests not working with @Transactional multi transaction managers

    Stack Overflow | 11 months ago | rpfujiw
    org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.transaction.PlatformTransactionManager] is defined: expected single matching bean but found 3: transactionManagerSqlServer,transactionManagerDB2,transactionManagerSqlServer2
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. org.springframework.beans.factory.NoUniqueBeanDefinitionException

    No qualifying bean of type [org.springframework.transaction.PlatformTransactionManager] is defined: expected single matching bean but found 18: transactionManagerSite-39,transactionManagerSite-18,transactionManagerSite-19,transactionManagerSite-34,transactionManagerSite-25,transactionManagerSite-36,transactionManagerSite-1,transactionManagerSite-10,transactionManagerSite-21,transactionManagerSite-32,transactionManagerSite-2,transactionManagerSite-11,transactionManagerSite-22,transactionManagerSite-33,transactionManagerSite-3,transactionManagerSite-4,transactionManagerSite-40,transactionManagerSite-8

    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean()
  2. Spring Beans
    DefaultListableBeanFactory.getBean
    1. org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:368)[DefaultListableBeanFactory.class:4.3.2.RELEASE]
    2. org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:334)[DefaultListableBeanFactory.class:4.3.2.RELEASE]
    2 frames
  3. Spring Tx
    TransactionInterceptor.invoke
    1. org.springframework.transaction.interceptor.TransactionAspectSupport.determineTransactionManager(TransactionAspectSupport.java:366)[TransactionAspectSupport.class:4.3.2.RELEASE]
    2. org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:270)[TransactionAspectSupport.class:4.3.2.RELEASE]
    3. org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)[TransactionInterceptor.class:4.3.2.RELEASE]
    3 frames
  4. Spring AOP
    ReflectiveMethodInvocation.proceed
    1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)[ReflectiveMethodInvocation.class:4.3.2.RELEASE]
    1 frame
  5. Spring Integration Core
    AbstractRequestHandlerAdvice$1.execute
    1. org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice$1.execute(AbstractRequestHandlerAdvice.java:75)[AbstractRequestHandlerAdvice$1.class:4.3.1.RELEASE]
    1 frame
  6. mypackagewebapp.spring.integration
    ExportHandlerAdvice.doInvoke
    1. mypackagewebapp.spring.integration.ExportHandlerAdvice.doInvoke(ExportHandlerAdvice.java:69)[ExportHandlerAdvice.class:na]
    1 frame
  7. Spring Integration Core
    AbstractRequestHandlerAdvice.invoke
    1. org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice.invoke(AbstractRequestHandlerAdvice.java:70)[AbstractRequestHandlerAdvice.class:4.3.1.RELEASE]
    1 frame
  8. Spring AOP
    JdkDynamicAopProxy.invoke
    1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)[ReflectiveMethodInvocation.class:4.3.2.RELEASE]
    2. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)[JdkDynamicAopProxy.class:4.3.2.RELEASE]
    2 frames
  9. com.sun.proxy
    $Proxy34.handleRequestMessage
    1. com.sun.proxy.$Proxy34.handleRequestMessage(Unknown Source)[na:na]
    1 frame