我在Arquillian测试用例的非常简单的实现中陷入困境。我按照Can I add jars to maven 2 build classpath without installing them?将项目jar添加到maven存储库。我使用Glassfish服务器作为我的应用程序服务器。 然后我需要编写arquillian测试用例 为此,我使用了以下代码
@Inject
private ControllerLoginModule controllerloginmodule;
@Deployment
public static WebArchive createDeployment()
{
File[] lib = Maven.resolver()
.resolve("com.controllerjars:controllerbeans:1.0.0","com.controllerjars:controllerapi:2.0.0","com.controllerjars:controllerauth:1.0.0")
.withTransitivity().as(File.class);
return ShrinkWrap.create(WebArchive.class, "test.war")
.addClasses(ControllerLoginModule.class,AuthRealm.class,IAccountManagerInternal.class)
.addAsLibraries(lib)
.addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml")
.addAsWebInfResource(new StringAsset("<web-app></web-app>"), "web.xml");
}
@Test
public void testIsDeployed()
{
Assert.assertNotNull(controllerloginmodule);
}
基本上我正在加载一些包含测试中的类以及这些类所依赖的类的jar。最后,我试图从中创建一个Web存档。 然后我尝试测试那个对象是否为空。
我可以从堆栈跟踪中找出的问题是部署无法从Maven中找到文件。下面是我尝试运行测试用例时观察到的堆栈跟踪。
java.lang.RuntimeException: Could not invoke deployment method: public static org.jboss.shrinkwrap.api.spec.WebArchive com.appdynamics.auth.ControllerLoginModuleTest.createDeployment()
at org.jboss.arquillian.container.test.impl.client.deployment.AnnotationDeploymentScenarioGenerator.invoke(AnnotationDeploymentScenarioGenerator.java:160)
at org.jboss.arquillian.container.test.impl.client.deployment.AnnotationDeploymentScenarioGenerator.generateDeployment(AnnotationDeploymentScenarioGenerator.java:94)
at org.jboss.arquillian.container.test.impl.client.deployment.AnnotationDeploymentScenarioGenerator.generate(AnnotationDeploymentScenarioGenerator.java:57)
at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.generateDeployment(DeploymentGenerator.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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.EventImpl.fire(EventImpl.java:67)
at org.jboss.arquillian.container.test.impl.client.ContainerEventController.execute(ContainerEventController.java:100)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
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.test.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:80)
at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:182)
at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)
at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)
at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:199)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)
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.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.arquillian.container.test.impl.client.deployment.AnnotationDeploymentScenarioGenerator.invoke(AnnotationDeploymentScenarioGenerator.java:156)
... 50 more
Caused by: java.lang.RuntimeException: Could not create new descriptor instance
at org.jboss.shrinkwrap.resolver.api.DependencyBuilderInstantiator.createFromUserView(DependencyBuilderInstantiator.java:101)
at org.jboss.shrinkwrap.resolver.api.DependencyResolvers.use(DependencyResolvers.java:39)
at com.appdynamics.auth.ControllerLoginModuleTest.createDeployment(ControllerLoginModuleTest.java:51)
... 55 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.jboss.shrinkwrap.resolver.api.DependencyBuilderInstantiator.createFromUserView(DependencyBuilderInstantiator.java:96)
... 57 more
Caused by: java.lang.NoSuchMethodError: org.codehaus.plexus.DefaultPlexusContainer.lookup(Ljava/lang/Class;)Ljava/lang/Object;
at org.jboss.shrinkwrap.resolver.impl.maven.MavenRepositorySystem.getRepositorySystem(MavenRepositorySystem.java:220)
at org.jboss.shrinkwrap.resolver.impl.maven.MavenRepositorySystem.<init>(MavenRepositorySystem.java:64)
at org.jboss.shrinkwrap.resolver.impl.maven.MavenBuilderImpl.<init>(MavenBuilderImpl.java:105)
... 62 more
我无法理解我遗失的地方和地点。我更新了Can I add jars to maven 2 build classpath without installing them?中给出的依赖项的条目。任何帮助是极大的赞赏。 感谢。
下面是我的pom
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!-- Model Information -->
<modelVersion>4.0.0</modelVersion>
<!-- Artifact Information -->
<groupId>com.auth</groupId>
<artifactId>controller.functionaltest</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<!-- Properties -->
<properties>
<version.shrinkwrap.resolver>2.0.0-beta-2</version.shrinkwrap.resolver>
<version.junit>4.11</version.junit>
<version.arquillian_core>1.0.3.Final</version.arquillian_core>
<project.basedir>/controller.functionaltest</project.basedir>
<version.org.jboss.shrinkwrap>1.1.2</version.org.jboss.shrinkwrap>
</properties>
<!-- Dependency Management -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-bom</artifactId>
<version>${version.shrinkwrap.resolver}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>${version.arquillian_core}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<!-- Dependencies -->
<dependencies>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${version.junit}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<version>${version.arquillian_core}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.controllerjars</groupId>
<artifactId>commonscollections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>com.controllerjars</groupId>
<artifactId>commonutil</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.controllerjars</groupId>
<artifactId>controllerapi</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.controllerjars</groupId>
<artifactId>controllerauth</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.controllerjars</groupId>
<artifactId>controllerbeans</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-depchain</artifactId>
<type>pom</type>
<version>2.0.0-beta-2</version>
</dependency>
</dependencies>
<!-- Repositories -->
<repositories>
<repository>
<id>JBOSS_NEXUS</id>
<url>http://repository.jboss.org/nexus/content/groups/public</url>
</repository>
<repository>
<releases>
<enabled>true</enabled>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>repo</id>
<url>file://${project.basedir}/src/main/resources</url>
</repository>
</repositories>
<!-- Plugin Configuration -->
<build>
<finalName>controller.functionaltest</finalName>
<!-- Compiler -->
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
<!-- Plugin Management -->
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-dependency-plugin
</artifactId>
<versionRange>[2.1,)</versionRange>
<goals>
<goal>unpack</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>GLASSFISH_REMOTE_3.1_(REST)</id>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<extensions>false</extensions>
<executions>
<execution>
<id>unpack</id>
<phase>process-test-classes</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-dist</artifactId>
<version>7.1.3.Final</version>
<type>zip</type>
<overWrite>false</overWrite>
<outputDirectory>~/JBOSS_Managed</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-glassfish-remote-3.1</artifactId>
<version>1.0.0.CR3</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>JBOSS_AS_MANAGED_7.X</id>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<extensions>false</extensions>
<executions>
<execution>
<id>unpack</id>
<phase>process-test-classes</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-dist</artifactId>
<version>7.1.3.Final</version>
<type>zip</type>
<overWrite>false</overWrite>
<outputDirectory>~/JBOSS_Managed</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-arquillian-container-managed</artifactId>
<version>7.1.3.Final</version>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
下面是我的依赖树。
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building controller.functionaltest 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ controller.functionaltest ---
[INFO] com.appdynamics.auth:controller.functionaltest:pom:1.0.0-SNAPSHOT
[INFO] +- org.jboss.spec:jboss-javaee-6.0:pom:1.0.0.Final:provided
[INFO] | +- org.jboss.spec.javax.annotation:jboss-annotations-api_1.1_spec:jar:1.0.0.Final:provided
[INFO] | +- org.jboss.spec.javax.resource:jboss-connector-api_1.5_spec:jar:1.0.0.Final:provided
[INFO] | +- org.jboss.spec.javax.ejb:jboss-ejb-api_3.1_spec:jar:1.0.0.Final:provided
[INFO] | | \- javax.xml:jaxrpc-api:jar:1.1:provided
[INFO] | +- org.jboss.spec.javax.el:jboss-el-api_2.2_spec:jar:1.0.0.Final:provided
[INFO] | +- org.jboss.spec.javax.interceptor:jboss-interceptors-api_1.1_spec:jar:1.0.0.Final:provided
[INFO] | +- org.jboss.spec.javax.security.jacc:jboss-jacc-api_1.4_spec:jar:1.0.0.Final:provided
[INFO] | +- org.jboss.spec.javax.enterprise.deploy:jboss-jad-api_1.2_spec:jar:1.0.0.Final:provided
[INFO] | +- org.jboss.spec.javax.security.auth.message:jboss-jaspi-api_1.0_spec:jar:1.0.0.Final:provided
[INFO] | +- org.jboss.spec.javax.xml.registry:jboss-jaxr-api_1.0_spec:jar:1.0.0.Final:provided
[INFO] | +- org.jboss.spec.javax.jms:jboss-jms-api_1.1_spec:jar:1.0.0.Final:provided
[INFO] | +- org.jboss.spec.javax.servlet.jsp:jboss-jsp-api_2.2_spec:jar:1.0.0.Final:provided
[INFO] | +- org.jboss.spec.javax.servlet:jboss-servlet-api_3.0_spec:jar:1.0.0.Final:provided
[INFO] | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.0.Final:provided
[INFO] | +- org.jboss.spec.javax.xml.bind:jboss-jaxb-api_2.2_spec:jar:1.0.0.Final:provided
[INFO] | +- org.jboss.spec.javax.xml.rpc:jboss-jaxrpc-api_1.1_spec:jar:1.0.0.Final:provided
[INFO] | +- org.jboss.spec.javax.xml.soap:jboss-saaj-api_1.3_spec:jar:1.0.0.Final:provided
[INFO] | +- org.jboss.spec.javax.xml.ws:jboss-jaxws-api_2.2_spec:jar:1.0.0.Final:provided
[INFO] | +- javax.activation:activation:jar:1.1:provided
[INFO] | +- javax.enterprise:cdi-api:jar:1.0-SP4:provided
[INFO] | +- com.sun.faces:jsf-api:jar:2.0.3-b05:provided
[INFO] | +- javax.inject:javax.inject:jar:1:provided
[INFO] | +- javax.jws:jsr181-api:jar:1.0-MR1:provided
[INFO] | +- javax.mail:mail:jar:1.4.2:provided
[INFO] | +- javax.servlet:jstl:jar:1.2:provided
[INFO] | +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.0.Final:provided
[INFO] | +- org.jboss.resteasy:jaxrs-api:jar:2.1.0.GA:provided
[INFO] | +- stax:stax-api:jar:1.0.1:provided
[INFO] | \- javax.validation:validation-api:jar:1.0.0.GA:provided
[INFO] +- junit:junit:jar:4.11:test (scope not updated to runtime)
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.jboss.arquillian.junit:arquillian-junit-container:jar:1.0.3.Final:test
[INFO] | +- org.jboss.arquillian.junit:arquillian-junit-core:jar:1.0.3.Final:test
[INFO] | +- org.jboss.arquillian.test:arquillian-test-api:jar:1.0.3.Final:test
[INFO] | | \- org.jboss.arquillian.core:arquillian-core-api:jar:1.0.3.Final:test
[INFO] | +- org.jboss.arquillian.test:arquillian-test-spi:jar:1.0.3.Final:test
[INFO] | | \- org.jboss.arquillian.core:arquillian-core-spi:jar:1.0.3.Final:test
[INFO] | +- org.jboss.arquillian.container:arquillian-container-test-api:jar:1.0.3.Final:test
[INFO] | +- org.jboss.arquillian.container:arquillian-container-test-spi:jar:1.0.3.Final:test
[INFO] | | \- org.jboss.arquillian.container:arquillian-container-spi:jar:1.0.3.Final:test
[INFO] | | \- org.jboss.shrinkwrap.descriptors:shrinkwrap-descriptors-api-base:jar:2.0.0-alpha-3:test
[INFO] | +- org.jboss.arquillian.core:arquillian-core-impl-base:jar:1.0.3.Final:test
[INFO] | +- org.jboss.arquillian.test:arquillian-test-impl-base:jar:1.0.3.Final:test
[INFO] | +- org.jboss.arquillian.container:arquillian-container-impl-base:jar:1.0.3.Final:test
[INFO] | | +- org.jboss.arquillian.config:arquillian-config-api:jar:1.0.3.Final:test
[INFO] | | +- org.jboss.arquillian.config:arquillian-config-impl-base:jar:1.0.3.Final:test
[INFO] | | \- org.jboss.shrinkwrap.descriptors:shrinkwrap-descriptors-spi:jar:2.0.0-alpha-3:test
[INFO] | \- org.jboss.arquillian.container:arquillian-container-test-impl-base:jar:1.0.3.Final:test
[INFO] +- com.controllerjars:commonscollections:jar:3.2.1:compile
[INFO] +- com.controllerjars:commonutil:jar:1.0.0:compile
[INFO] +- com.controllerjars:controllerapi:jar:2.0.0:compile
[INFO] +- com.controllerjars:controllerauth:jar:1.0.0:compile
[INFO] +- com.controllerjars:controllerbeans:jar:1.0.0:compile
[INFO] \- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-depchain:pom:2.0.0-beta-2:compile
[INFO] +- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-api:jar:2.0.0-beta-2:compile
[INFO] +- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-spi:jar:2.0.0-beta-2:compile
[INFO] +- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-api-maven:jar:2.0.0-beta-2:compile
[INFO] +- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-impl-maven:jar:2.0.0-beta-2:runtime
[INFO] | +- org.sonatype.aether:aether-api:jar:1.13.1:runtime
[INFO] | +- org.sonatype.aether:aether-impl:jar:1.13.1:runtime
[INFO] | +- org.sonatype.aether:aether-spi:jar:1.13.1:runtime
[INFO] | +- org.sonatype.aether:aether-util:jar:1.13.1:runtime
[INFO] | +- org.sonatype.aether:aether-connector-wagon:jar:1.13.1:runtime
[INFO] | +- org.apache.maven:maven-aether-provider:jar:3.0.4:runtime
[INFO] | +- org.apache.maven:maven-model:jar:3.0.4:runtime
[INFO] | +- org.apache.maven:maven-model-builder:jar:3.0.4:runtime
[INFO] | +- org.apache.maven:maven-repository-metadata:jar:3.0.4:runtime
[INFO] | +- org.apache.maven:maven-settings:jar:3.0.4:runtime
[INFO] | +- org.apache.maven:maven-settings-builder:jar:3.0.4:runtime
[INFO] | +- org.codehaus.plexus:plexus-interpolation:jar:1.14:runtime
[INFO] | +- org.codehaus.plexus:plexus-utils:jar:2.0.6:runtime
[INFO] | +- org.apache.maven.wagon:wagon-provider-api:jar:2.2:runtime
[INFO] | +- org.apache.maven.wagon:wagon-file:jar:2.2:runtime
[INFO] | \- org.apache.maven.wagon:wagon-http-lightweight:jar:2.2:runtime
[INFO] | \- org.apache.maven.wagon:wagon-http-shared4:jar:2.2:runtime
[INFO] | +- org.jsoup:jsoup:jar:1.6.1:runtime
[INFO] | +- org.apache.httpcomponents:httpcore:jar:4.1.2:runtime
[INFO] | \- commons-io:commons-io:jar:2.0.1:runtime
[INFO] \- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-impl-maven-archive:jar:2.0.0-beta-2:runtime
[INFO] +- org.jboss.shrinkwrap:shrinkwrap-impl-base:jar:1.0.1:runtime
[INFO] | +- org.jboss.shrinkwrap:shrinkwrap-api:jar:1.0.1:runtime
[INFO] | \- org.jboss.shrinkwrap:shrinkwrap-spi:jar:1.0.1:runtime
[INFO] +- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-api-maven-archive:jar:2.0.0-beta-2:runtime
[INFO] +- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-spi-maven-archive:jar:2.0.0-beta-2:runtime
[INFO] +- org.codehaus.plexus:plexus-compiler-javac:jar:2.1:runtime
[INFO] | \- org.codehaus.plexus:plexus-compiler-api:jar:2.1:runtime
[INFO] \- org.codehaus.plexus:plexus-component-api:jar:1.0-alpha-33:runtime
[INFO] \- org.codehaus.plexus:plexus-classworlds:jar:1.2-alpha-10:runtime
答案 0 :(得分:2)
我认为这个问题的原因是由于模糊的ShrinkWrap Resolver依赖性。您应该在Arquillian BOM之前在依赖关系管理链中声明ShrinkWrap Resolver物料清单。我建议使用ShrinkWrap Resolver 2.0.0-beta-2。
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-bom</artifactId>
<version>2.0.0-beta-2</version>
<scope>test</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>${arquillian.version}</version>
<scope>test</scope>
<type>pom</type>
</dependency>
</dependencyManagement>
在依赖项部分中,您需要具有以下依赖项:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-depchain</artifactId>
<type>pom</type>
<version>2.0.0-beta-2</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<version>${arquillian.version}</version>
<scope>test</scope>
</dependency>
ShrinkWrap Resolver 2.0.0-beta-2提供了一个用于解决工件的新API,因此您需要确保使用该特定API,例如:
File lib = Maven.resolver()
.resolve("artifact-groupid:artifact-artifactid:version")
.withoutTransitivity()
.asSingle(File.class);
return ShrinkWrap.create(WebArchive.class, "test.war")
.addClass(MyClass.class)
.addAsLibrary(lib)
.addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml")
.addAsWebInfResource(new StringAsset("<web-app></web-app>"), "web.xml");
我创建了一个示例项目,其中包含使用ShrinkWrap Resolver所需的最小值,该解析器使用上面的配置和代码,但是在嵌入式TomEE容器中运行。你可以在这里找到它:https://github.com/tommysdk/showcase/tree/master/arquillian-shrinkres。希望这可以帮助您直接找出所需的正确依赖项和版本。
答案 1 :(得分:1)
我有同样的问题。原因是无法访问资源文件。例如:
.addAsWebResource("index.html")
Index.html 文件在测试运行时期间必须在classpath中,否则抛出的异常是(!):
java.lang.RuntimeException:无法调用部署方法:public static org.jboss.shrinkwrap.api.Archive com.intrasoft.ssp.persistence.admin.service.IndexPageTest.createDeployment()
答案 2 :(得分:0)
您的POM看起来似乎是由于Arquillian BOM和ShrinkWrap Resolvers depchain引入的ShrinkWrap工件之间的冲突或缺失依赖性。
通过the POM snippet here,我相信您还应该在项目POM中的Arquillian BOM之前将ShrinkWrap Resolver BOM添加为托管依赖项。