DeployableContainer 在运行 Arquillian 时必须指定错误

2022-09-04 07:24:13

我一直在尝试运行这个Arquillian示例

https://github.com/arquillian/arquillian-examples/tree/master/arquillian-tutorial

在 Eclipse 中导入时没有错误

但是,当我作为JUnit测试运行时,我收到此错误:

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:93)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:156)
    ... 10 more
Caused by: org.jboss.arquillian.container.impl.ContainerCreationException: Could not create Container jbossas-managed
    at org.jboss.arquillian.container.impl.LocalContainerRegistry.create(LocalContainerRegistry.java:85)
    at org.jboss.arquillian.container.impl.client.container.ContainerRegistryCreator.createRegistry(ContainerRegistryCreator.java:76)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
    at org.jboss.arquillian.core.impl.ManagerImpl.bindAndFire(ManagerImpl.java:236)
    at org.jboss.arquillian.core.impl.InstanceImpl.set(InstanceImpl.java:74)
    at org.jboss.arquillian.config.impl.extension.ConfigurationRegistrar.loadConfiguration(ConfigurationRegistrar.java:68)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
    at org.jboss.arquillian.core.impl.ManagerImpl.start(ManagerImpl.java:261)
    at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.<init>(EventTestRunnerAdaptor.java:56)
    ... 15 more
Caused by: java.lang.IllegalArgumentException: DeployableContainer must be specified
    at org.jboss.arquillian.core.spi.Validate.notNull(Validate.java:44)
    at org.jboss.arquillian.container.impl.ContainerImpl.<init>(ContainerImpl.java:71)
    at org.jboss.arquillian.container.impl.LocalContainerRegistry.create(LocalContainerRegistry.java:76)
    ... 39 more

答案 1

项目 POM 定义了一堆配置文件 - 、 和 。默认情况下,它们都不是活动的。您需要激活其中一个来运行测试,因为配置文件引入了Arquillian容器适配器。arquillian-weld-ee-embeddedarquillian-glassfish-embeddedarquillian-jbossas-managed

如果类路径中没有容器适配器,则可能会看到异常,并显示消息“必须指定 DeployableContainer”。java.lang.IllegalArgumentException


答案 2

似乎QuickStrat的描述非常模糊。要默认启用配置文件,您只需添加:arq-jboss-remote

 <activation>
       <activeByDefault>true</activeByDefault>
 </activation>

添加到项目中的此配置文件定义中。pom.xml


推荐