java.lang.IllegalStateException: There are two concurrently open transactions!


 T E S T S


Running tests.WorkWithDataBaseTest

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.802 sec <<< FAILURE!

testGetMessage(tests.WorkWithDataBaseTest)  Time elapsed: 0.648 sec  <<< ERROR!

java.lang.IllegalStateException: There are two concurrently open transactions!




 at org.junit.runners.BlockJUnit4ClassRunner.runChild(

 at org.junit.runners.BlockJUnit4ClassRunner.runChild(

 at org.junit.runners.ParentRunner$

 at org.junit.runners.ParentRunner$1.schedule(

 at org.junit.runners.ParentRunner.runChildren(

 at org.junit.runners.ParentRunner.access$000(

 at org.junit.runners.ParentRunner$2.evaluate(


 at org.apache.maven.surefire.junit4.JUnit4Provider.execute(

 at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(

 at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(

 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

 at sun.reflect.NativeMethodAccessorImpl.invoke(

 at sun.reflect.DelegatingMethodAccessorImpl.invoke(

 at java.lang.reflect.Method.invoke(

 at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(

 at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(

 at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(

 at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(

 at org.apache.maven.surefire.booter.ForkedBooter.main(


Running ut.test.MyComponentUnitTest

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec


Results :


Tests in error: 

  testGetMessage(tests.WorkWithDataBaseTest): There are two concurrently open transactions!

Help me, please 

2 answers

1 vote


I know this is quite old already, but in case somebody stumbles upon this - if you Debug your test code you will notice that the exception is actually raised after the test, when the ActiveObjects object is being destroyed, I guess it tries to rollback everything you haven't committed during the test or so, not exactly sure

I was able to solve this issue by appending the @NonTransactional annotation to my test method - see also the Javadocs for ActiveObjectsJUnitRunner:

* By default, each test method is executed within a separate transaction, which is then rolled back so the
* next test is executed with a fresh database state. If you annotate a test method with
* {@link NonTransactional @NonTransactional}, then it is not executed inside a transaction; instead, the
* database is completely reinitialized after executing the test.


Hope this helps someone :D

How do you know that your code is performing transactionally? I want to use NonTransactionl annotation but then I don't know what is happening in the back end. Also, all my database calls are transactional.

0 votes

Which Atlassian application is it, what are the tests, and what is your code doing that causes it?


import static org.junit.Assert.*;

import java.util.Date;
import java.util.List;


import com.atlassian.activeobjects.external.ActiveObjects;
import com.atlassian.activeobjects.test.TestActiveObjects;
import com.atlassian.activeobjects.tx.Transactional;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.atlassian.sal.api.user.UserManager;

import ua.jdroidcoder.entitys.MessageEntity;
import ua.jdroidcoder.workwithdatabase.IWorkWithDataBase;
import ua.jdroidcoder.workwithdatabase.WorkWithDataBase;

public final class WorkWithDataBaseTest {

private IWorkWithDataBase workWithDataBase;
private EntityManager entityManager;
private ActiveObjects ao;

public void setUp() throws Exception{
ao = new TestActiveObjects(entityManager);
workWithDataBase = new WorkWithDataBase(ao);

public void testGetMessage(){

assertEquals(1, ao.find(MessageEntity.class).length);
workWithDataBase.addNewMessage("test", "test", new Date(), "test", "test", "test");

public static class ServiceImplTestDatabaseUpdater implements DatabaseUpdater
public void update(EntityManager em) throws Exception

final MessageEntity todo = em.create(MessageEntity.class);
todo.setDate(new Date());;

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 24, 2018 in Confluence

Atlassian Research opportunity with Confluence templates

Do you use templates with Confluence? Take part in a remote 1-hr workshop. You'll receive USD $100 for your time!   We're looking for people to participate in a   remote 1-hr workshop...

1,099 views 17 14
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you