我试图做一个使用在WildFly 8.1.0服务器上远程启动的Arquillian测试的模块化项目。一切都在逃避,但只有当我从我的IDE启动测试时。当詹金斯试图做同样的事情时,它失败并出现错误:
SEVERE [domain.testframework.logic.UserPersistTest] : org.jboss.shrinkwrap.resolver.api.Invokable$InvocationException: Unable to invoke onlyOne([Ljava.lang.Class;@5d79653) on object org.jboss.shrinkwrap.resolver.spi.loader.ServiceRegistry with parameters [Ljava.lang.Object;@cce2624
at org.jboss.shrinkwrap.resolver.api.Invokable.invokeMethod(Invokable.java:108) [shrinkwrap-resolver-api-2.1.1.jar:2.1.1]
at org.jboss.shrinkwrap.resolver.api.ResolverSystemFactory.createFromUserView(ResolverSystemFactory.java:91) [shrinkwrap-resolver-api-2.1.1.jar:2.1.1]
at org.jboss.shrinkwrap.resolver.api.ResolverSystemFactory.createFromUserView(ResolverSystemFactory.java:53) [shrinkwrap-resolver-api-2.1.1.jar:2.1.1]
at org.jboss.shrinkwrap.resolver.api.Resolvers.use(Resolvers.java:68) [shrinkwrap-resolver-api-2.1.1.jar:2.1.1]
at org.jboss.shrinkwrap.resolver.api.maven.Maven.resolver(Maven.java:36) [shrinkwrap-resolver-api-maven-2.1.1.jar:2.1.1]
at domain.testframework.logic.UserPersistTest.createDeployment(UserPersistTest.java:61) [:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_13]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_13]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_13]
at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_13]
at org.jboss.arquillian.container.test.impl.client.deployment.AnnotationDeploymentScenarioGenerator.invoke(AnnotationDeploymentScenarioGenerator.java:177) [arquillian-container-test-impl-base-1.1.5.Final.jar:1.1.5.Final]
at org.jboss.arquillian.container.test.impl.client.deployment.AnnotationDeploymentScenarioGenerator.generateDeployment(AnnotationDeploymentScenarioGenerator.java:103) [arquillian-container-test-impl-base-1.1.5.Final.jar:1.1.5.Final]
at org.jboss.arquillian.container.test.impl.client.deployment.AnnotationDeploymentScenarioGenerator.generate(AnnotationDeploymentScenarioGenerator.java:64) [arquillian-container-test-impl-base-1.1.5.Final.jar:1.1.5.Final]
at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.generateDeployment(DeploymentGenerator.java:79) [arquillian-container-test-impl-base-1.1.5.Final.jar:1.1.5.Final]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_13]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_13]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_13]
at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_13]
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) [arquillian-core-impl-base-1.1.5.Final.jar:1.1.5.Final]
at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99) [arquillian-core-impl-base-1.1.5.Final.jar:1.1.5.Final]
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81) [arquillian-core-impl-base-1.1.5.Final.jar:1.1.5.Final]
at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145) [arquillian-core-impl-base-1.1.5.Final.jar:1.1.5.Final]
at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116) [arquillian-core-impl-base-1.1.5.Final.jar:1.1.5.Final]
at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67) [arquillian-core-impl-base-1.1.5.Final.jar:1.1.5.Final]
at org.jboss.arquillian.container.test.impl.client.ContainerEventController.execute(ContainerEventController.java:100) [arquillian-container-test-impl-base-1.1.5.Final.jar:1.1.5.Final]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_13]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_13]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_13]
at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_13]
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) [arquillian-core-impl-base-1.1.5.Final.jar:1.1.5.Final]
at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99) [arquillian-core-impl-base-1.1.5.Final.jar:1.1.5.Final]
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81) [arquillian-core-impl-base-1.1.5.Final.jar:1.1.5.Final]
at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:84) [arquillian-test-impl-base-1.1.5.Final.jar:1.1.5.Final]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_13]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_13]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_13]
at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_13]
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) [arquillian-core-impl-base-1.1.5.Final.jar:1.1.5.Final]
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) [arquillian-core-impl-base-1.1.5.Final.jar:1.1.5.Final]
at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:65) [arquillian-test-impl-base-1.1.5.Final.jar:1.1.5.Final]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_13]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_13]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_13]
at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_13]
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) [arquillian-core-impl-base-1.1.5.Final.jar:1.1.5.Final]
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) [arquillian-core-impl-base-1.1.5.Final.jar:1.1.5.Final]
at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145) [arquillian-core-impl-base-1.1.5.Final.jar:1.1.5.Final]
at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116) [arquillian-core-impl-base-1.1.5.Final.jar:1.1.5.Final]
at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:80) [arquillian-test-impl-base-1.1.5.Final.jar:1.1.5.Final]
at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:190) [arquillian-junit-core-1.1.5.Final.jar:1.1.5.Final]
at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:345) [arquillian-junit-core-1.1.5.Final.jar:1.1.5.Final]
at org.jboss.arquillian.junit.Arquillian.access$200(Arquillian.java:49) [arquillian-junit-core-1.1.5.Final.jar:1.1.5.Final]
at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:207) [arquillian-junit-core-1.1.5.Final.jar:1.1.5.Final]
at org.junit.runners.ParentRunner.run(ParentRunner.java:309) [junit-4.11.jar:]
at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:155) [arquillian-junit-core-1.1.5.Final.jar:1.1.5.Final]
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264) [surefire-junit4-2.17.jar:2.17]
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153) [surefire-junit4-2.17.jar:2.17]
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124) [surefire-junit4-2.17.jar:2.17]
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200) [surefire-booter-2.17.jar:2.17]
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153) [surefire-booter-2.17.jar:2.17]
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103) [surefire-booter-2.17.jar:2.17]
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_13]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_13]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_13]
at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_13]
at org.jboss.shrinkwrap.resolver.api.Invokable.invokeMethod(Invokable.java:100) [shrinkwrap-resolver-api-2.1.1.jar:2.1.1]
... 60 more
Caused by: java.lang.RuntimeException: Could not create new service instance
at org.jboss.shrinkwrap.resolver.spi.loader.SpiServiceLoader.createInstance(SpiServiceLoader.java:248) [shrinkwrap-resolver-spi-2.1.1.jar:2.1.1]
at org.jboss.shrinkwrap.resolver.spi.loader.SpiServiceLoader.createInstances(SpiServiceLoader.java:208) [shrinkwrap-resolver-spi-2.1.1.jar:2.1.1]
at org.jboss.shrinkwrap.resolver.spi.loader.SpiServiceLoader.all(SpiServiceLoader.java:79) [shrinkwrap-resolver-spi-2.1.1.jar:2.1.1]
at org.jboss.shrinkwrap.resolver.spi.loader.SpiServiceLoader.onlyOne(SpiServiceLoader.java:85) [shrinkwrap-resolver-spi-2.1.1.jar:2.1.1]
at org.jboss.shrinkwrap.resolver.spi.loader.ServiceRegistry.onlyOne(ServiceRegistry.java:117) [shrinkwrap-resolver-spi-2.1.1.jar:2.1.1]
... 65 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.7.0_13]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) [rt.jar:1.7.0_13]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [rt.jar:1.7.0_13]
at java.lang.reflect.Constructor.newInstance(Constructor.java:525) [rt.jar:1.7.0_13]
at org.jboss.shrinkwrap.resolver.spi.loader.SpiServiceLoader.createInstance(SpiServiceLoader.java:244) [shrinkwrap-resolver-spi-2.1.1.jar:2.1.1]
... 69 more
Caused by: org.jboss.shrinkwrap.resolver.api.InvalidConfigurationFileException: Unable to get security configuration from /root/.m2/settings-security.xml. Please define path to the settings-security.xml file via -Dorg.apache.maven.security-settings, or put it the the default location defined by Maven.
at org.jboss.shrinkwrap.resolver.impl.maven.internal.decrypt.MavenSecurityDispatcher.getMaster(MavenSecurityDispatcher.java:171) [shrinkwrap-resolver-impl-maven-2.1.1.jar:2.1.1]
at org.jboss.shrinkwrap.resolver.impl.maven.internal.decrypt.MavenSecurityDispatcher.decrypt(MavenSecurityDispatcher.java:96) [shrinkwrap-resolver-impl-maven-2.1.1.jar:2.1.1]
at org.jboss.shrinkwrap.resolver.impl.maven.internal.decrypt.MavenSettingsDecrypter.decrypt(MavenSettingsDecrypter.java:92) [shrinkwrap-resolver-impl-maven-2.1.1.jar:2.1.1]
at org.jboss.shrinkwrap.resolver.impl.maven.internal.decrypt.MavenSettingsDecrypter.decrypt(MavenSettingsDecrypter.java:60) [shrinkwrap-resolver-impl-maven-2.1.1.jar:2.1.1]
at org.jboss.shrinkwrap.resolver.impl.maven.bootstrap.MavenSettingsBuilder.decryptPasswords(MavenSettingsBuilder.java:223) [shrinkwrap-resolver-impl-maven-2.1.1.jar:2.1.1]
at org.jboss.shrinkwrap.resolver.impl.maven.bootstrap.MavenSettingsBuilder.buildSettings(MavenSettingsBuilder.java:186) [shrinkwrap-resolver-impl-maven-2.1.1.jar:2.1.1]
at org.jboss.shrinkwrap.resolver.impl.maven.bootstrap.MavenSettingsBuilder.buildDefaultSettings(MavenSettingsBuilder.java:113) [shrinkwrap-resolver-impl-maven-2.1.1.jar:2.1.1]
at org.jboss.shrinkwrap.resolver.impl.maven.MavenWorkingSessionImpl.<init>(MavenWorkingSessionImpl.java:136) [shrinkwrap-resolver-impl-maven-2.1.1.jar:2.1.1]
at org.jboss.shrinkwrap.resolver.impl.maven.MavenResolverSystemImpl.<init>(MavenResolverSystemImpl.java:44) [shrinkwrap-resolver-impl-maven-2.1.1.jar:2.1.1]
... 74 more
@Deployment方法
@Deployment
public static WebArchive createDeployment() {
File pom = new File("pom.xml");
LOG.info("---->>" + pom);
File[] libs = null;
try {
libs = Maven.resolver().loadPomFromFile(pom)
.importRuntimeDependencies().resolve().withTransitivity().asFile();
} catch (Throwable exception) {
LOG.log(Level.SEVERE, "", exception);
}
LOG.info("LIBS RESOLVED: " + libs.length);
for (File lib : libs) {
System.out.println(lib);
}
WebArchive archive = ShrinkWrap.create(WebArchive.class, "ShrinkWrap-arquillian-test.war")
.addAsWebInfResource("web.xml")
.addClass(User.class)
.addAsResource("test-persistence.xml", "META-INF/persistence.xml")
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
for (File lib : libs) {
if (!lib.toString().contains("test-framework-data")) {
archive.addAsLibrary(lib);
}
}
}
知道为什么会这样吗?
我的父母POM
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>domain</groupId>
<artifactId>test-framework-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>test-framework-web</module>
<module>test-framework-logic</module>
<module>test-framework-data</module>
<module>test-framework-ear</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java-version>1.7</java-version>
<!--Wersje pluginów-->
<ejb-plugin-version>2.3</ejb-plugin-version>
<war-plugin-version>2.4</war-plugin-version>
<ear-plugin-version>2.9</ear-plugin-version>
<compiler-plugin-version>3.1</compiler-plugin-version>
<maven-dependency-plugin-version>2.8</maven-dependency-plugin-version>
<!--Wersje zależności-->
<javaee-api-version>7.0</javaee-api-version>
<shrinkwrap.bom-version>2.1.1</shrinkwrap.bom-version>
<postgreslq.version>9.1-901-1.jdbc4</postgreslq.version>
<!--Wersja EJB-->
<ejb-spec-version>3.2</ejb-spec-version>
<!--Wersje środowiska testowego-->
<surefire-plugin-version>2.17</surefire-plugin-version>
<junit-version>4.11</junit-version>
<arquillian-version>1.1.5.Final</arquillian-version>
<wildfly-version>8.1.0.Final</wildfly-version>
<arquillian-wildfly-version>8.1.0.Final</arquillian-wildfly-version>
<arquillian-transaction-version>1.0.1.Final</arquillian-transaction-version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>${javaee-api-version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-bom</artifactId>
<version>${shrinkwrap.bom-version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-depchain</artifactId>
<version>${shrinkwrap.bom-version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-transaction-bom</artifactId>
<version>${arquillian-transaction-version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-remote</artifactId>
<version>8.1.0.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>${arquillian-version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgreslq.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>${ear-plugin-version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>${maven-dependency-plugin-version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin-version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin-version}</version>
<configuration>
<source>${java-version}</source>
<target>${java-version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>${ejb-plugin-version}</version>
<configuration>
<ejbVersion>${ejb-spec-version}</ejbVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${war-plugin-version}</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
<webResources>
<resource>
<filtering>true</filtering>
<directory>src/main/webapp</directory>
<includes>
<include>**/web.xml</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<name>test-framework</name>
</project>
答案 0 :(得分:0)
解决这个问题有点微不足道。
问题在于maven存储库的settings.xml。我有本地存储库,其中包含<password>{123}abc</password>
等凭据。
Maven.resolver()需要修改<password>\{123\}abc</password>
,否则它会查找文件'settings-security.xml'。我已经修改了这个文件的本地副本,但是在服务器上它没有被更改。