例外:运行Arquillian测试时,为DeployableContainer接口找到了多个服务实现

时间:2017-05-31 08:00:35

标签: maven intellij-idea wildfly jboss-arquillian jboss-forge

我试图按照示例项目"反馈"来自Continuous Enterprise Development in Java, ch. 3并进行了一些修改。

我使用的是IntelliJ Idea及其JBoss-Forge插件,与本书中使用的控制台不同。

到目前为止,我已经创建了一个具有以下特征的新项目:

  • Java 1.8
  • JEE 7
  • Wildfly 10.1.0.Final
  • JUnit 4.12
  • Arquillian 1.1.13.0
  • 休眠
  • Maven个人资料:arquillian-wildfly-remote

我已经完成了教程中的每一步,都使用了IntelliJ插件:

  • 设置ACCEPT_DEFAULTS为真
  • 创建了项目
  • 使用Hibernate设置持久性
  • 使用Hibernate验证器设置验证
  • 创建实体FeedbackEntry
  • 搭建UI
  • forge install-plugin arquillian
  • 使用Wildfly远程容器设置Arquillian
  • 创建了一个Arquillian
  • 构建并部署应用

所有这些都成功结束,我可以打开UI并在数据库中存储一些值。尝试运行测试时出现问题:我创建了一个 Wildfly Remote Arquillian容器:

Creating arquillian container

enter image description here

单击OK后,这是我得到的堆栈跟踪:

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:166)
    at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:103)
    at org.jboss.arquillian.test.spi.TestRunnerAdaptorBuilder.build(TestRunnerAdaptorBuilder.java:52)
    at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:114)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:162)
    ... 8 more
Caused by: org.jboss.arquillian.container.impl.ContainerCreationException: Could not create Container arquillian-wildfly-remote
    at org.jboss.arquillian.container.impl.LocalContainerRegistry.create(LocalContainerRegistry.java:85)
    at org.jboss.arquillian.container.impl.client.container.ContainerRegistryCreator.createRegistry(ContainerRegistryCreator.java:78)
    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.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:96)
    at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:103)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:85)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:143)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:114)
    at org.jboss.arquillian.core.impl.ManagerImpl.bindAndFire(ManagerImpl.java:263)
    at org.jboss.arquillian.core.impl.InstanceImpl.set(InstanceImpl.java:74)
    at org.jboss.arquillian.config.impl.extension.ConfigurationRegistrar.loadConfiguration(ConfigurationRegistrar.java:73)
    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.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:96)
    at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:103)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:85)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:143)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:114)
    at org.jboss.arquillian.core.impl.ManagerImpl.start(ManagerImpl.java:288)
    at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.<init>(EventTestRunnerAdaptor.java:63)
    ... 13 more
Caused by: java.lang.IllegalStateException: Multiple service implementations found for interface org.jboss.arquillian.container.spi.client.container.DeployableContainer. org.jboss.as.arquillian.container.remote.RemoteDeployableContainer, org.arquillian.container.chameleon.ChameleonContainer
    at org.jboss.arquillian.core.impl.loadable.ServiceRegistryLoader.onlyOne(ServiceRegistryLoader.java:74)
    at org.jboss.arquillian.container.impl.LocalContainerRegistry.create(LocalContainerRegistry.java:76)
    ... 37 more


Test ignored.

Test ignored.

Process finished with exit code 255

我在很多地方搜索过,我只找到this。但是,我不认为我有超过1个容器,只有Wildfly,所以我对此完全无能为力。

Pom和其​​他关键文件:https://gist.github.com/josemigallas/a139fc601b022356391fad5b2ec588b0

为什么会失败?如何解决/解决此问题?

2 个答案:

答案 0 :(得分:1)

根据我的经验,Arquillian插件或IDEA Maven支持可能会导致激活配置文件时出现问题。请确保默认情况下arquillian-wildfly-remote已启用(如果已勾选则取消勾选并再次勾选:))。也可以使用常规JUnit运行程序运行测试,而不是使用Arquillian运行程序。

答案 1 :(得分:0)

我认为使用带有Arquillian支持的IntelliJ时会出现问题。你能尝试从CLI运行吗?