Arquillian gradle importer / resolver无法创建WebArchive

时间:2015-10-16 17:43:01

标签: java java-ee gradle jboss-arquillian

我正在尝试使用Arquillian在Wildfly 8上测试我的测试。我的项目是使用Gradle工具构建的。

我的项目有一个依赖项,我正在尝试使用我的WarArchive,包括在build.gradle文件中声明的依赖项。

plugins {
    id 'java'
    id 'war'
}

repositories {
    maven { url 'https://repository.jboss.org/nexus/content/groups/public-jboss' }  
    maven { url 'https://repository.jboss.org/nexus/content/repositories' }  
    maven { url 'https://repository.jboss.org/nexus/content/repositories/thirdparty-releases' }
    mavenCentral()
}


dependencies {

    providedCompile 'org.jboss.spec:jboss-javaee-7.0:1.0.3.Final'

    compile group: 'com.mysema.querydsl', name: 'querydsl-collections', version: '3.6.7'

    testCompile 'junit:junit:4.12'
    testCompile 'org.jboss.arquillian.junit:arquillian-junit-container:1.1.9.Final'
    testCompile 'org.jboss.arquillian:arquillian-bom:1.1.9.Final'
    testCompile 'org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-api-gradle-embedded-archive:2.2.0'
    testRuntime 'org.wildfly:wildfly-arquillian-container-embedded:8.2.1.Final'
    testRuntime 'org.wildfly:wildfly-embedded:8.2.1.Final'
    testRuntime 'org.jboss.logging:jboss-logging:3.3.0.Final'

    testCompile 'org.jboss.weld:weld-core:2.3.0.Final'
    testCompile 'org.jboss.shrinkwrap:shrinkwrap-depchain:1.2.2'
    testCompile 'org.slf4j:slf4j-simple:1.7.12'
}

test {
    systemProperty 'java.util.logging.manager', 'org.jboss.logmanager.LogManager'

    testLogging {
        events 'passed', 'skipped', 'failed'
        exceptionFormat = 'full'
    }
}

我的测试课程是:

@RunWith(Arquillian.class)
public class SimpleTest
{

    @Inject private SingleEntity singleEntity;

    @Deployment
    public static JavaArchive createDeployment()
    {   
        return ShrinkWrap.create(EmbeddedGradleImporter.class).forThisProjectDirectory().importBuildOutput().as(JavaArchive.class);
    }

    @Test
    public void categorize()
    {
        assertNotNull(this.singleEntity);
    }
}

当我执行gradle test时,Wildfly正确地进行了测试。然而,当测试Arquillian试图创建WarArchive时,它会崩溃:

java.lang.RuntimeException: Could not invoke deployment method: public static org.jboss.shrinkwrap.api.spec.JavaArchive com.jeusdi.arquillian.SimpleTest.createDeployment()
    at org.jboss.arquillian.container.test.impl.client.deployment.AnnotationDeploymentScenarioGenerator.invoke(AnnotationDeploymentScenarioGenerator.java:181)
    at org.jboss.arquillian.container.test.impl.client.deployment.AnnotationDeploymentScenarioGenerator.generateDeployment(AnnotationDeploymentScenarioGenerator.java:103)
    at org.jboss.arquillian.container.test.impl.client.deployment.AnnotationDeploymentScenarioGenerator.generate(AnnotationDeploymentScenarioGenerator.java:64)
    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:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    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.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:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    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:92)
    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:483)
    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: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:483)
    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:145)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)
    at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:87)
    at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:201)
    at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:422)
    at org.jboss.arquillian.junit.Arquillian.access$200(Arquillian.java:54)
    at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:218)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:166)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:86)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:49)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:64)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:50)
    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:483)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
    at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
    at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:106)
    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:483)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:360)
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
    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:483)
    at org.jboss.arquillian.container.test.impl.client.deployment.AnnotationDeploymentScenarioGenerator.invoke(AnnotationDeploymentScenarioGenerator.java:177)
    ... 69 more
Caused by: org.jboss.shrinkwrap.api.UnknownExtensionTypeException: The current configuration has no mapping for type org.jboss.shrinkwrap.api.gradle.archive.importer.embedded.EmbeddedGradleImporter, unable to determine extension. You should provide extension in the services descriptor file
    at org.jboss.shrinkwrap.api.UnknownExtensionTypeException.newInstance(UnknownExtensionTypeException.java:68)
    at org.jboss.shrinkwrap.api.UnknownExtensionTypeExceptionDelegator.newExceptionInstance(UnknownExtensionTypeExceptionDelegator.java:37)
    at org.jboss.shrinkwrap.impl.base.ServiceExtensionLoader.findExtensionImpl(ServiceExtensionLoader.java:279)
    at org.jboss.shrinkwrap.impl.base.ServiceExtensionLoader.loadExtensionMapping(ServiceExtensionLoader.java:246)
    at org.jboss.shrinkwrap.impl.base.ServiceExtensionLoader.getExtensionFromExtensionMapping(ServiceExtensionLoader.java:160)
    at org.jboss.shrinkwrap.api.ArchiveFactory.create(ArchiveFactory.java:104)
    at org.jboss.shrinkwrap.api.ShrinkWrap.create(ShrinkWrap.java:136)
    at com.jeusdi.arquillian.SimpleTest.createDeployment(SimpleTest.java:26)
    ... 74 more

1 个答案:

答案 0 :(得分:0)

你在说那个

  

,我试图使用我的WarArchive

并且您有一个war插件,但您的代码正在执行:

.importBuildOutput().as(JavaArchive.class);

请尝试:

.importBuildOutput().as(WebArchive.class);

这可能会解决您的问题

  

无法确定扩展名。