Jakarta ee Arquillian-在org.jboss.Arquillian.core.api.threading.ExecutorService上找不到类

Jakarta ee Arquillian-在org.jboss.Arquillian.core.api.threading.ExecutorService上找不到类,jakarta-ee,classnotfoundexception,executorservice,jboss-arquillian,Jakarta Ee,Classnotfoundexception,Executorservice,Jboss Arquillian,我目前正试图让arquillian工作,但我的一个单元测试有问题。它在类org.jboss.arquillian.core.api.threading.ExecutorService上的CLassNotFoundException失败。也许我忘记了pom.xml中的依赖性,或者我误解了一些东西,但我无法解决这个问题 以下是stacktrace: java.lang.RuntimeException: Could not create new instance of class org.jboss

我目前正试图让arquillian工作,但我的一个单元测试有问题。它在类
org.jboss.arquillian.core.api.threading.ExecutorService
上的CLassNotFoundException失败。也许我忘记了pom.xml中的依赖性,或者我误解了一些东西,但我无法解决这个问题

以下是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
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;
    }
}
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");
    }
}

为什么在
org.jboss.arquillian.core.api.threading.ExecutorService
上有
ClassNotFoundException
?知道问题出在哪里吗?

类加载器中可能有一个较旧版本的arquillian核心api导致了这一问题

尝试使用arquillian bom管理所有arquillian依赖项的正确版本,如下所示:

<dependencyManagement>
   <dependencies>
     <dependency>
        <groupId>org.jboss.arquillian</groupId>
        <artifactId>arquillian-bom</artifactId>
        <version>1.1.4.Final</version>
        <scope>import</scope>
        <type>pom</type>
    </dependency>
   </dependencies>
</dependencyManagement>

org.jboss.arquillian

尝试添加

<dependency>
        <groupId>org.jboss.arquillian.core</groupId>
        <artifactId>arquillian-core-api</artifactId>
        <version>1.1.4.Final</version>
        <scope>test</scope>
</dependency>

org.jboss.arquillian.core
arquillian核心api
1.1.4.最终版本
测试
<dependency>
        <groupId>org.jboss.arquillian.core</groupId>
        <artifactId>arquillian-core-api</artifactId>
        <version>1.1.4.Final</version>
        <scope>test</scope>
</dependency>