java.lang.IllegalStateException: No matching PlatformTransactionManager bean found for qualifier 'transactionManagerExt' - neither qualifier match nor bean name match!

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • When I specify qualifier for @Transactional annotation and the specified PlatformTransactionManager is defined in parent context, the exception is thrown like following: {code} java.lang.IllegalStateException: No matching PlatformTransactionManager bean found for qualifier 'transactionManagerExt' - neither qualifier match nor bean name match! at org.springframework.transaction.interceptor.TransactionAspectUtils.getTransactionManager(TransactionAspectUtils.java:91) at org.springframework.transaction.interceptor.TransactionAspectUtils.getTransactionManager(TransactionAspectUtils.java:53) at org.springframework.transaction.interceptor.TransactionAspectSupport.determineTransactionManager(TransactionAspectSupport.java:245) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:100) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621) {code} For example, if the autowired bean with {{@Transactional}}-marked method is being parsed in servlet-level context, but {{transactionManager}} is specified in the global web-application context, defined by {{contextConfigLocation}} param in web.xml. So actually Spring does not take in account here parent contexts. Investigating the code I have found the class {{TransactionAspectUtils}} with the following method {{isQualifierMatch()}} which uses {{bf.containsBeanDefinition}} method which of course is not parent-aware! My suggestion is to change this method call either to {{bf.containsBean}} or to implement recursive bean searching through contexts hierarchy.
    via by Derar Bakr,
  • When I specify qualifier for @Transactional annotation and the specified PlatformTransactionManager is defined in parent context, the exception is thrown like following: {code} java.lang.IllegalStateException: No matching PlatformTransactionManager bean found for qualifier 'transactionManagerExt' - neither qualifier match nor bean name match! at org.springframework.transaction.interceptor.TransactionAspectUtils.getTransactionManager(TransactionAspectUtils.java:91) at org.springframework.transaction.interceptor.TransactionAspectUtils.getTransactionManager(TransactionAspectUtils.java:53) at org.springframework.transaction.interceptor.TransactionAspectSupport.determineTransactionManager(TransactionAspectSupport.java:245) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:100) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621) {code} For example, if the autowired bean with {{@Transactional}}-marked method is being parsed in servlet-level context, but {{transactionManager}} is specified in the global web-application context, defined by {{contextConfigLocation}} param in web.xml. So actually Spring does not take in account here parent contexts. Investigating the code I have found the class {{TransactionAspectUtils}} with the following method {{isQualifierMatch()}} which uses {{bf.containsBeanDefinition}} method which of course is not parent-aware! My suggestion is to change this method call either to {{bf.containsBean}} or to implement recursive bean searching through contexts hierarchy.
    via by Derar Bakr,
  • Background: In our product we use Hibernate with Spring's declarative transaction demarcation (via an HibernateTransactionManager). One of the capabilities of our product is to execute arbitrary user-define SQL commands using unrelated user-defined data sources. We have an outer transaction that loads this configuration for the SQL command and data source via Hibernate. To process the user's SQL we create a DataSourceTransactionManager programatically. Then we execute the SQL via a JdbcTemplate & PreparedStatementCallback and programmatically commit/rollback our transaction. All is ok unless the user's Data Source definition is incorrect (or their database is down) in which case our call to the PlatformTransactionManager getTransaction(...) throws the corresponding SQLException. The exception is thrown out to the transaction interceptor for the Hibernate transaction which attempts to roll that transaction back too. The problem seems to be that the 'outer' Hibernate transaction was suspended when we called PlatformTransactionManager getTransaction(...) but it was not automatically resumed when the getTransaction failed. Thus the following IllegalStateException occurs when it finally tries to rollback... java.lang.IllegalStateException: Cannot deactivate transaction synchronization - not active at org.springframework.transaction.support.TransactionSynchronizationManager.clearSynchronization(TransactionSynchronizationManager.java:274) at org.springframework.transaction.support.TransactionSynchronizationManager.clear(TransactionSynchronizationManager.java:412) at org.springframework.transaction.support.AbstractPlatformTransactionManager.cleanupAfterCompletion(AbstractPlatformTransactionManager.java:905) at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:774) at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:719) at org.springframework.transaction.interceptor.TransactionAspectSupport.completeTransactionAfterThrowing(TransactionAspectSupport.java:329) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:111) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:203) at $Proxy126.process(Unknown Source) This does not appear to be related to Hibernate or to declarative transactions. The following test case (using JMock) code replicates the problem: public class SqlDispatcherTest extends MockObjectTestCase { private static final SQLException CONNECT_EXCEPTION = new SQLException( "Cannot connect"); public void testTransactionSuspension_UnconnectableDataSource() throws Exception { try { // Create an outer transaction final PlatformTransactionManager txMgrOuter = new DataSourceTransactionManager( createDataSourceStub(createConnectionStub())); final TransactionStatus txOuter = txMgrOuter .getTransaction(new DefaultTransactionDefinition()); try { // Create inner transaction (not nested, though: unrelated data // source) final PlatformTransactionManager txMgrInner = new DataSourceTransactionManager( createUnconnectableDataSourceStub()); final TransactionStatus txInner = txMgrInner .getTransaction(new DefaultTransactionDefinition( TransactionDefinition.PROPAGATION_REQUIRES_NEW)); try { // Do something with the connection that succeeds or fails // (but we dont get this far) // etc, etc... txMgrInner.commit(txInner); } catch (Exception e) { txMgrInner.rollback(txInner); throw e; } txMgrOuter.commit(txOuter); } catch (Exception e) { txMgrOuter.rollback(txOuter); throw e; } fail("Exception should be thrown"); } catch (SQLException e) { assertSame("Should be thrown exception", CONNECT_EXCEPTION, e); } } private DataSource createDataSourceStub(Connection connection) { Mock mockDataSource = mock(DataSource.class); DataSource dataSource = (DataSource) mockDataSource.proxy(); mockDataSource.stubs().method("getConnection").will( returnValue(connection)); return dataSource; } private Connection createConnectionStub() { Mock mockConnection = mock(Connection.class); mockConnection.stubs().method("getAutoCommit").will(returnValue(false)); mockConnection.stubs().method("rollback"); mockConnection.stubs().method("commit"); return (Connection) mockConnection.proxy(); } private DataSource createUnconnectableDataSourceStub() { Mock mockDataSource = mock(DataSource.class); DataSource dataSource = (DataSource) mockDataSource.proxy(); mockDataSource.stubs().method("getConnection").will( throwException(CONNECT_EXCEPTION)); return dataSource; } }
    via by Jeremy Stone,
    • java.lang.IllegalStateException: No matching PlatformTransactionManager bean found for qualifier 'transactionManagerExt' - neither qualifier match nor bean name match! at org.springframework.transaction.interceptor.TransactionAspectUtils.getTransactionManager(TransactionAspectUtils.java:91) at org.springframework.transaction.interceptor.TransactionAspectUtils.getTransactionManager(TransactionAspectUtils.java:53) at org.springframework.transaction.interceptor.TransactionAspectSupport.determineTransactionManager(TransactionAspectSupport.java:245) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:100) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)
    No Bugmate found.