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 com.google.common.base.Preconditions.checkState(Preconditions.java:145)

 at net.java.ao.DatabaseProvider.rollbackTransaction(DatabaseProvider.java:888)

 at net.java.ao.test.junit.ActiveObjectTransactionMethodRule$1.evaluate(ActiveObjectTransactionMethodRule.java:85)

 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)

 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)

 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)

 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)

 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)

 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)

 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)

 at org.junit.runners.ParentRunner.run(ParentRunner.java:236)

 at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)

 at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)

 at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)

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

 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

 at java.lang.reflect.Method.invoke(Method.java:498)

 at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)

 at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)

 at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)

 at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)

 at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

 

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 


1 answer

0 vote

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 net.java.ao.test.converters.NameConverters;
import net.java.ao.test.jdbc.Data;
import net.java.ao.test.jdbc.DatabaseUpdater;
import net.java.ao.test.jdbc.DynamicJdbcConfiguration;
import net.java.ao.test.jdbc.Jdbc;
import net.java.ao.test.junit.ActiveObjectsJUnitRunner;
import net.java.ao.EntityManager;

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;

@RunWith(ActiveObjectsJUnitRunner.class)
@Jdbc(DynamicJdbcConfiguration.class)
@Data(WorkWithDataBaseTest.ServiceImplTestDatabaseUpdater.class)
public final class WorkWithDataBaseTest {

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

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

@Test
public void testGetMessage(){

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

public static class ServiceImplTestDatabaseUpdater implements DatabaseUpdater
{
@Override
public void update(EntityManager em) throws Exception
{
em.migrate(MessageEntity.class);

final MessageEntity todo = em.create(MessageEntity.class);
todo.setSubject("test");
todo.setContent("test");
todo.setImage("test");
todo.setAuthorAvatar("test");
todo.setAuthor("test");
todo.setDate(new Date());
todo.save();
}
}
}

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

2,927 views 27 12
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