我在JBoss AS 7下使用Arquillian和TestNG来测试Maven项目,它运行得很好。我将 htmlunit 添加到我的POM之后:
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.9</version>
<scope>provided</scope>
</dependency>
Arquillian测试立即开始崩溃,出现以下错误:
FAILED CONFIGURATION: @BeforeSuite arquillianBeforeSuite
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.testng.Arquillian.arquillianBeforeSuite(Arquillian.java:64)
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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:277)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
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)
... 22 more
Caused by: java.lang.NoClassDefFoundError: org/apache/xml/serializer/TreeWalker
at org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:823)
at __redirected.__TransformerFactory.newTransformer(__TransformerFactory.java:133)
at org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomDescriptorExporterImpl.to(XmlDomDescriptorExporterImpl.java:66)
at org.jboss.shrinkwrap.descriptor.spi.node.NodeDescriptorExporterImpl.to(NodeDescriptorExporterImpl.java:55)
at org.jboss.shrinkwrap.descriptor.spi.node.NodeDescriptorExporterImpl.to(NodeDescriptorExporterImpl.java:30)
at org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomDescriptorExporter.to(XmlDomDescriptorExporter.java:51)
at org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomDescriptorExporter.to(XmlDomDescriptorExporter.java:34)
at org.jboss.shrinkwrap.descriptor.spi.node.NodeDescriptorImplBase.exportTo(NodeDescriptorImplBase.java:55)
at org.jboss.shrinkwrap.descriptor.spi.DescriptorImplBase.exportAsString(DescriptorImplBase.java:84)
at org.jboss.arquillian.config.impl.extension.ConfigurationSysPropResolver.resolveSystemProperties(ConfigurationSysPropResolver.java:54)
at org.jboss.arquillian.config.impl.extension.ConfigurationRegistrar.loadConfiguration(ConfigurationRegistrar.java:62)
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)
... 27 more
Caused by: java.lang.ClassNotFoundException: org.apache.xml.serializer.TreeWalker
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 49 more
我对JBoss和Maven的了解有限,但似乎问题是 htmlunit 依赖于 xalan ,这显然也被Arquillian使用,但是我不知道为什么会搞砸。有什么想法吗?
答案 0 :(得分:0)
事实证明,存档 serializer-2.7.1.jar 是 xalan 的一部分,在JBoss中打包不正确(无法解压缩) Maven存储库。像这样的错误是一个真正的调试难题,因为没有错误消息指向实际问题(谢谢,Java)。无论如何,我通过将相同的存档从JBoss安装复制到本地Maven存储库来解决了这个问题。