Arquillian - 已在模块中定义的组件

时间:2015-03-19 12:41:18

标签: java maven jboss-arquillian

我正在尝试设置Arquillian并且我总是得到一个堆栈跟踪:

13:37:29,432 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC00001: Failed to start service jboss.deployment.unit."6bf136f5-6ea1-43e0-a521-76250a489921.war".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."6bf136f5-6ea1-43e0-a521-76250a489921.war".PARSE: Failed to process phase PARSE of deployment "6bf136f5-6ea1-43e0-a521-76250a489921.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_71]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_71]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_71]
Caused by: java.lang.IllegalArgumentException: JBAS011046: A component named 'ValidationServiceImpl' is already defined in this module
at org.jboss.as.ee.component.EEModuleDescription.addComponent(EEModuleDescription.java:137)
at org.jboss.as.ejb3.deployment.processors.EJBComponentDescriptionFactory.addComponent(EJBComponentDescriptionFactory.java:60)
at org.jboss.as.ejb3.deployment.processors.SessionBeanComponentDescriptionFactory.processSessionBeans(SessionBeanComponentDescriptionFactory.java:157)
at org.jboss.as.ejb3.deployment.processors.SessionBeanComponentDescriptionFactory.processAnnotations(SessionBeanComponentDescriptionFactory.java:86)
at org.jboss.as.ejb3.deployment.processors.AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.processAnnotations(AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.java:58)
at org.jboss.as.ejb3.deployment.processors.AbstractDeploymentUnitProcessor.deploy(AbstractDeploymentUnitProcessor.java:81)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
... 5 more

我的arquillian测试按以下方式设置:

@RunWith(Arquillian.class)
public class ECadDocumentServiceImplTestIT {
private static final boolean RECURSIVE = true;

static Logger logger = Logger.getLogger(ECadDocumentServiceImplTestIT.class);

@Inject
private ECadDocumentService eCadDocumentService;

@Deployment
public static WebArchive getServiceDeployment() {
    File settingsFile = new File(System.getProperty("maven.execution.global-settings"));
    File pomFile = new File(System.getProperty("maven.execution.pom-file"));

    File[] libs = Maven.configureResolver()
            .fromFile(settingsFile)
            .loadPomFromFile(pomFile)
            .importRuntimeAndTestDependencies().resolve().withTransitivity().asFile();

    WebArchive war = ShrinkWrap.create(WebArchive.class)
            .addAsLibraries(libs)
            .addPackages(true, ECadDocumentService.class.getPackage())
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
            .addAsResource("test-persistence.xml", "META-INF/persistence.xml");
    return war;
}


@Test
public void test() throws EcadError {
    ApplicationIdentification applicationIdent = ApplicationIdentificationMother.valid(0);
    DocumentTreatmentResponse dtr = eCadDocumentService.addDocument(ApplicantIdentityMother.valid(), applicationIdent, DocumentIdentificationMother.valid(), DocumentFingerprintMother.valid());
    assertEquals(applicationIdent.getApplicationId(), dtr.getApplicationID());
}

}

我正在添加libs,因为我正在使用apache.commons.net依赖项。否则我得到一个“classNotFoundException”。

有没有人有任何想法?我没有两次名为'ValidationServiceImpl'的课程。

1 个答案:

答案 0 :(得分:0)

也许重复的类进入了ECadDocumentService的包和你从pom文件解析的某个库中。 尝试分享有关项目布局的更多信息,或者至少有关于测试和有问题的类的位置以及pom.file中包含的对您自己的项目的依赖关系,您将获得库。

您可以保存部署档案(在部署之前),将下一个选项添加到arquillian.xml文件中。

<engine>
    <property name="deploymentExportPath">target/deployments</property>
</engine>

有关详细信息,请参阅此处导出部署arquillian guide

部分

此致