I'm currently trying to make arquillian works but I have a problem on one of my Unit Test. It fails on a CLassNotFoundException on class org.jboss.arquillian.core.api.threading.ExecutorService
. Maybe I forgot a dependancy in my pom.xml, or I misunderstood something but I cannot solve this issue.
Here is the stacktrace :
java.lang.RuntimeException: Could not create new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor
at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:160)
at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:111)
at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:97)
at org.jboss.arquillian.test.spi.TestRunnerAdaptorBuilder.build(TestRunnerAdaptorBuilder.java:52)
at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:95)
at org.junit.runners.Suite.runChild(Suite.java:127)
at org.junit.runners.Suite.runChild(Suite.java:26)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runners.Suite.runChild(Suite.java:127)
at org.junit.runners.Suite.runChild(Suite.java:26)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runners.Suite.runChild(Suite.java:127)
at org.junit.runners.Suite.runChild(Suite.java:26)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:156)
... 37 more
Caused by: java.lang.RuntimeException: Could not create new instance of class org.jboss.arquillian.core.impl.ManagerImpl
at org.jboss.arquillian.core.spi.SecurityActions.newInstance(SecurityActions.java:160)
at org.jboss.arquillian.core.spi.SecurityActions.newInstance(SecurityActions.java:111)
at org.jboss.arquillian.core.spi.SecurityActions.newInstance(SecurityActions.java:97)
at org.jboss.arquillian.core.spi.ManagerBuilder.create(ManagerBuilder.java:77)
at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.<init>(EventTestRunnerAdaptor.java:55)
... 42 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.jboss.arquillian.core.spi.SecurityActions.newInstance(SecurityActions.java:156)
... 46 more
Caused by: java.lang.NoClassDefFoundError: org/jboss/arquillian/core/api/threading/ExecutorService
at org.jboss.arquillian.core.impl.ManagerImpl$3.call(ManagerImpl.java:470)
at org.jboss.arquillian.core.impl.ManagerImpl.executeInApplicationContext(ManagerImpl.java:242)
at org.jboss.arquillian.core.impl.ManagerImpl.createBuiltInServices(ManagerImpl.java:465)
at org.jboss.arquillian.core.impl.ManagerImpl.<init>(ManagerImpl.java:94)
... 51 more
Caused by: java.lang.ClassNotFoundException: org.jboss.arquillian.core.api.threading.ExecutorService
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 55 more
Here are the files :
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>be.normegil</groupId>
<artifactId>librarium</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>librarium</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.7</version>
</dependency>
<!-- Apache Commons -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.1</version>
</dependency>
<!-- JEE 7 - API -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
<!-- JEE 7 - JPA -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.4.Final</version>
</dependency>
<!-- TEST DEPENDANCIES -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<version>1.1.4.Final</version>
<scope>test</scope>
</dependency>
<!-- REST Testing framework -->
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>rest-assured</artifactId>
<version>2.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-embedded</artifactId>
<version>8.1.0.CR1</version>
<scope>test</scope>
</dependency>
</dependencies>
<!-- Used by persistence.xml in test resources -->
<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
</build>
</project>
GameREST.java
package be.normegil.librarium.rest;
import be.normegil.librarium.model.dao.GameDAO;
import be.normegil.librarium.model.data.Game;
import org.apache.commons.lang3.Validate;
import javax.inject.Inject;
import javax.ws.rs.*;
import java.util.Collection;
@Path("/games")
public class GameREST {
private GameDAO gameDAO;
@GET
@Path("/all")
@Produces("application/json")
public Collection<Game> getGamesList() {
return gameDAO.getAll();
}
@GET
@Path("{ID}")
@Produces("application/json")
public Game getGame(@PathParam("ID") Long id) {
Validate.notNull(id);
return gameDAO.get(id);
}
@PUT
@Path("{Name}")
@Produces("application/json")
public void createGame(@PathParam("Name") String name) {
Validate.notNull(name);
Game game = new Game(name);
gameDAO.save(game);
}
@POST
@Path("{ID}/{Name}")
public void updateGame(@PathParam("ID") Long id,
@PathParam("Name") String name) {
Validate.notNull(id);
Validate.notNull(name);
Game game = gameDAO.get(id);
if(game == null){
throw new IllegalArgumentException("No game found for ID : " + id);
}
game.setName(name);
gameDAO.save(game);
}
@DELETE
@Path("{ID}")
public void deleteGame(@PathParam("ID") Long id) {
Validate.notNull(id);
Game game = gameDAO.get(id);
if(game == null){
throw new IllegalArgumentException("No game found for ID : " + id);
}
gameDAO.remove(game);
}
@Inject
public void setGameDAO(final GameDAO gameDAO) {
this.gameDAO = gameDAO;
}
}
GameRESTTestREST.java
package be.normegil.librarium.rest;
import be.normegil.librarium.LibrariumApplication;
import org.apache.http.HttpStatus;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import static com.jayway.restassured.RestAssured.expect;
@RunWith(Arquillian.class)
public class GameRESTTestREST {
@Deployment
public static WebArchive createTestArchive() {
return ShrinkWrap.create(WebArchive.class)
.addClass(GameREST.class)
.addClass(LibrariumApplication.class);
}
@Test
@RunAsClient
public void testGetAll() throws Exception {
expect()
.statusCode(HttpStatus.SC_OK)
.log().ifError()
.when()
.get("/games/all");
}
}
Why do I have a ClassNotFoundException
on org.jboss.arquillian.core.api.threading.ExecutorService
? Any idea where the problem is ?