来自IDEA官方指南的arquillian运行时问题

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了来自IDEA官方指南的arquillian运行时问题相关的知识,希望对你有一定的参考价值。

我严格按照IDEA官方指南(https://www.jetbrains.com/help/idea/arquillian-a-quick-start-guide.html)的步骤逐一进行。 enter image description here所有maven依赖项都是正确的,依赖项的版本与文章提到的完全相同。没有编译问题。但是当我尝试在嵌入式容器中运行示例代码时(我使用指南提到的GlassFish Embedded 3.1),我遇到了运行时问题:

*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:165)
    at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:102)
    at org.jboss.arquillian.test.spi.TestRunnerAdaptorBuilder.build(TestRunnerAdaptorBuilder.java:52)
    at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:113)
    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:47)
    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:161)
    ... 8 more
Caused by: java.lang.NoClassDefFoundError: org/glassfish/embeddable/GlassFishException
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
    at java.lang.Class.getConstructor0(Class.java:3075)
    at java.lang.Class.getDeclaredConstructor(Class.java:2178)
    at org.jboss.arquillian.core.impl.loadable.SecurityActions$2.run(SecurityActions.java:192)
    at org.jboss.arquillian.core.impl.loadable.SecurityActions$2.run(SecurityActions.java:189)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.jboss.arquillian.core.impl.loadable.SecurityActions.getConstructor(SecurityActions.java:188)
    at org.jboss.arquillian.core.impl.loadable.SecurityActions.newInstance(SecurityActions.java:157)
    at org.jboss.arquillian.core.impl.loadable.ServiceRegistryLoader.createServiceInstance(ServiceRegistryLoader.java:103)
    at org.jboss.arquillian.core.impl.loadable.ServiceRegistryLoader.all(ServiceRegistryLoader.java:55)
    at org.jboss.arquillian.core.impl.loadable.ServiceRegistryLoader.onlyOne(ServiceRegistryLoader.java:67)
    at org.jboss.arquillian.container.impl.client.container.ContainerRegistryCreator.createRegistry(ContainerRegistryCreator.java:99)
    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: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:145)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)
    at org.jboss.arquillian.core.impl.ManagerImpl.bindAndFire(ManagerImpl.java:265)
    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: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:145)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)
    at org.jboss.arquillian.core.impl.ManagerImpl.start(ManagerImpl.java:290)
    at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.<init>(EventTestRunnerAdaptor.java:63)
    ... 13 more
Caused by: java.lang.ClassNotFoundException: org.glassfish.embeddable.GlassFishException
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

    ... 49 more*

有没有人指出问题是什么?有没有人试试这个并遵循该指南?在此先感谢!任何帮助将不胜感激!

答案

对于我在示例中看到的他们正在使用托管工件并且您正在尝试嵌入工件,因此我建议打开pom.xml并添加嵌入工件(Arquillian one和Glassfish)以便能够运行它。

https://docs.jboss.org/author/display/ARQ/GlassFish+3.1+-+Embedded

此外,如果你想要新的定义容器的方法是使用变色龙(https://github.com/arquillian/arquillian-container-chameleon)当然两者都有效,但后来更容易。

以上是关于来自IDEA官方指南的arquillian运行时问题的主要内容,如果未能解决你的问题,请参考以下文章

Arquillian:嵌入野蝇?

使用 Arquillian 和 Wildfly 进行集成测试

Openliberty arquillian 测试

是否可以使用arquillian资源进行参数化测试?

使用 Postgres DB 的 Arquillian 的 Tomee 用户缺少权限或找不到对象

SpringBoot 2.x 以War包外置Tomcat启动的标准做法-来自Spring官方指南