java.lang.IllegalStateException: Cannot start a new transaction without ending the existing transaction. at org.springframework.test.context.transaction.TransactionalTestExecutionListener.beforeTestMethodTransactionalTestExecutionListener.java:175)

Spring JIRA | Alan Boshier | 2 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    This is similar but not identical to SPR-12245. Our base class tests are annotated as follows: {code:java} @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class, TransactionalTestExecutionListener.class, DbUnitTestExecutionListener.class }) @DbUnitConfiguration( databaseOperationLookup=ExtendedDatabaseOperationLookup.class, dataSetLoader=ColumnSensingDataSetLoader.class) public abstract class FooTestBase extends AbstractTransactionalJUnit4SpringContextTests implements FooTestInterface {code} ... with an annotated subclass: {code:java} @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(value = "/foo-context-test.xml") @TransactionConfiguration(defaultRollback = true) @Transactional public class FooTest extends FooTestBase { {code} In moving from Spring 4.0 to 4.1 we are seeing many of our tests fail with: {noformat} java.lang.IllegalStateException: Cannot start a new transaction without ending the existing transaction. at org.springframework.test.context.transaction.TransactionalTestExecutionListener.beforeTestMethodTransactionalTestExecutionListener.java:175) at org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:249) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:72) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:73) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:217) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:83) {noformat}

    Spring JIRA | 2 years ago | Alan Boshier
    java.lang.IllegalStateException: Cannot start a new transaction without ending the existing transaction. at org.springframework.test.context.transaction.TransactionalTestExecutionListener.beforeTestMethodTransactionalTestExecutionListener.java:175)
  2. 0

    This is similar but not identical to SPR-12245. Our base class tests are annotated as follows: {code:java} @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class, TransactionalTestExecutionListener.class, DbUnitTestExecutionListener.class }) @DbUnitConfiguration( databaseOperationLookup=ExtendedDatabaseOperationLookup.class, dataSetLoader=ColumnSensingDataSetLoader.class) public abstract class FooTestBase extends AbstractTransactionalJUnit4SpringContextTests implements FooTestInterface {code} ... with an annotated subclass: {code:java} @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(value = "/foo-context-test.xml") @TransactionConfiguration(defaultRollback = true) @Transactional public class FooTest extends FooTestBase { {code} In moving from Spring 4.0 to 4.1 we are seeing many of our tests fail with: {noformat} java.lang.IllegalStateException: Cannot start a new transaction without ending the existing transaction. at org.springframework.test.context.transaction.TransactionalTestExecutionListener.beforeTestMethodTransactionalTestExecutionListener.java:175) at org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:249) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:72) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:73) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:217) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:83) {noformat}

    Spring JIRA | 2 years ago | Alan Boshier
    java.lang.IllegalStateException: Cannot start a new transaction without ending the existing transaction. at org.springframework.test.context.transaction.TransactionalTestExecutionListener.beforeTestMethodTransactionalTestExecutionListener.java:175)
  3. 0

    "Failed to retrieve PlatformTransactionManager" error when upgrading spring from 4.1.7 to 4.3.2

    Stack Overflow | 1 week ago | Paulo Merson
    java.lang.IllegalStateException: Failed to retrieve PlatformTransactionManager for @Transactional test for test context [DefaultTestContext@497aec8c testClass = TesteMBeanDialogoAtivarSessao, testInstance = br.gov.tcu.arquitetura.test.util.contexto.TesteMBeanDialogoAtivarSessao@3b9632d1, testMethod = testarMBeanDialogoAtivarSessao@TesteMBeanDialogoAtivarSessao, testException = [null], mergedContextConfiguration = [MergedContextConfiguration@64f16277 testClass = TesteMBeanDialogoAtivarSessao, locations = '{}', classes = '{class br.gov.tcu.arquitetura.tu.spring.config.SpringTestConfig}', contextInitializerClasses = '[]', activeProfiles = '{tu}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextCustomizers = set[[empty]], contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]]].
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalStateException

      Cannot start a new transaction without ending the existing transaction. at org.springframework.test.context.transaction.TransactionalTestExecutionListener.beforeTestMethodTransactionalTestExecutionListener.java:175)

      at org.springframework.test.context.TestContextManager.beforeTestMethod()
    2. Spring TestContext
      RunBeforeTestMethodCallbacks.evaluate
      1. org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:249)
      2. org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:72)
      2 frames
    3. JUnit
      RunAfters.evaluate
      1. org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      1 frame
    4. Spring TestContext
      SpringRepeat.evaluate
      1. org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
      2. org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:73)
      2 frames
    5. JUnit
      ParentRunner.runLeaf
      1. org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
      1 frame
    6. Spring TestContext
      SpringJUnit4ClassRunner.runChild
      1. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:217)
      2. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:83)
      2 frames