Hi folks!
I've worked through the atlassian tutorial for active objects: https://developer.atlassian.com/display/DOCS/Getting+Started+with+Active+Objects
But in the end, I dont get the unit tests running. I always get this error:
java.lang.IllegalAccessError: tried to access method net.java.ao.DatabaseProvider.<init>(Lnet/java/ao/DisposableDataSource;Ljava/lang/String;)V from class net.java.ao.builder.SupportedDatabase$8 at net.java.ao.builder.SupportedDatabase$8.getDatabaseProvider(SupportedDatabase.java:82) at net.java.ao.builder.DatabaseProviderFactory.getDatabaseProvider(DatabaseProviderFactory.java:10) at net.java.ao.builder.EntityManagerBuilderWithDatabaseProperties.build(EntityManagerBuilderWithDatabaseProperties.java:49) at net.java.ao.test.junit.ActiveObjectTransactionMethodRule.createEntityManager(ActiveObjectTransactionMethodRule.java:135) at net.java.ao.test.junit.ActiveObjectTransactionMethodRule.before(ActiveObjectTransactionMethodRule.java:61) at net.java.ao.test.junit.ActiveObjectTransactionMethodRule$1.evaluate(ActiveObjectTransactionMethodRule.java:45)
StackOverflow says this error is thrown most likely when the classes are loaded by different classloaders. I don't have a clue what is going on inside...
Here is my pom.xml for the test:
<!-- TEST dependencies--> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> <version>1.8.5</version> <scope>test</scope> </dependency> <dependency> <groupId>com.atlassian.activeobjects</groupId> <artifactId>activeobjects-test</artifactId> <version>0.19.7</version> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8</version> <scope>test</scope> </dependency> <dependency> <groupId>hsqldb</groupId> <artifactId>hsqldb</artifactId> <version>1.8.0.10</version> <scope>test</scope> </dependency>
and the testclass:
import com.atlassian.activeobjects.external.ActiveObjects; import com.atlassian.activeobjects.test.TestActiveObjects; import java.util.Date; import java.util.List; import net.java.ao.EntityManager; import net.java.ao.test.junit.ActiveObjectsJUnitRunner; import org.junit.After; import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @RunWith(ActiveObjectsJUnitRunner.class) public class OtrsArticleServiceImplTest { public EntityManager entityManager; private ActiveObjects ao; private OtrsArticleServiceImpl service; @Before public void setUpClass() throws Exception { assertNotNull(entityManager); ao = new TestActiveObjects(entityManager); service = new OtrsArticleServiceImpl(ao); } @After public void tearDownClass() throws Exception { } /** * Test of add method, of class OtrsArticleServiceImpl. */ @Test public void testAdd() { System.out.println("add"); Long ticketID = 23L; Long ownerID = 2L; Date created = new Date(); Long accTime = 23400L; ao.migrate(OtrsArticle.class); assertEquals(0, ao.find(OtrsArticle.class).length); final OtrsArticle article = service.add(ticketID, ownerID, accTime, created); assertFalse(article.getID() == 0); ao.flushAll(); // clear all caches final OtrsArticle[] articles = ao.find(OtrsArticle.class); assertEquals(1, articles.length); assertEquals(ticketID, articles[0].getTicketID()); assertEquals(created, articles[0].getCreated()); } }
thanks in advance!
Community moderators have prevented the ability to post new answers.
Hi Arthur,
I tried to compare your pom dependencies with mine and found this one in my pom:
<dependency> <groupId>net.java.dev.activeobjects</groupId> <artifactId>activeobjects-test</artifactId> <version>${ao.version}</version> <scope>test</scope> <type>jar</type> </dependency>
And try to use a newer ActiveObjects version. There should be a 0.23 or newer.
Regards
Steve
have you tried http://mavenhub.com/?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i tried 0.23 but it seems this is not an legit version. Do you know where I can find a list of versions for this component? maybe just the maven download link for this component.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey cool, I searched again for "active objects" here and found someone with the same problem. And he solved it using version 0.20. I switched to 0.20 and it works!! Great.
Thank you for pointing me in the right direction!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Is this the full stacktrace of the exception? Can you please paste the whole pom.xml?
Have you tried with a newer version of activeobjects-test?
It is unlikely that this is caused by a class-loading problem, as the caller classes and the class which contains the constructor being called are in the same jar and unit tests are not executed in in OSGi environment, where the class wiring is different.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.