gpt4 book ai didi

java - Arquillian - 模块中已定义组件

转载 作者:太空宇宙 更新时间:2023-11-04 14:02:55 24 4
gpt4 key购买 nike

我正在尝试设置 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());
}

}

我添加库是因为我正在使用 apache.commons.net 依赖项。否则我会收到“classNotFoundException”。

有人知道吗?我没有两次名为“ValidationServiceImpl”的类。

最佳答案

也许重复的类位于 ECADDocumentService 的包中以及您从 pom 文件解析的某个库中。尝试分享有关您的项目布局的更多信息,或者至少分享测试和有问题的类的位置以及您自己的项目的依赖项,这些信息包含在从您获取的库中的 pom.file 中。

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

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

在此处导出部署 arquillian guide 部分中有更多相关信息。

问候

关于java - Arquillian - 模块中已定义组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29144885/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com