java - pom 中的 Arquillian ShrinkWrap maven 依赖项

标签 java maven jboss jboss-arquillian

因此,正如另一个线程中的建议( Arquillian ShrinkWrap 已切换到托管容器(Jboss AS 7.1),现在错误不同

新的依赖关系管理(请参阅原始问题的上一个链接)

<dependencyManagement>
    <dependencies>
    <dependency>
        <groupId>org.jboss.shrinkwrap.resolver</groupId>
        <artifactId>shrinkwrap-resolver-bom</artifactId>
        <version>2.1.2</version>
        <scope>test</scope>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>org.jboss.arquillian</groupId>
        <artifactId>arquillian-bom</artifactId>
        <version>1.1.5.Final</version>
        <scope>test</scope>
        <type>pom</type>
    </dependency>
    </dependencies>
</dependencyManagement>

然后 我必须添加

    <dependency>
        <groupId>org.jboss.arquillian.core</groupId>
        <artifactId>arquillian-core-api</artifactId>
        <version>1.1.4.Final</version>
        <scope>test</scope>
    </dependency>

因为我有一个异常(exception)

Caused by: java.lang.NoClassDefFoundError: org/jboss/arquillian/core/api/threading/ExecutorService

现在 Jboss 本地实例上的部署似乎工作正常(一旦我有一点时间,我将使用更简单的测试进行测试,但我认为一切都很好) 本质上,问题是将maven(mistral-be,不属于此maven项目的一部分)中存在的jar依赖项添加到已部署的测试中(请参阅此问题的描述(Arquillian ShrinkWrap))。 最后我使用这个代码

String str = "C:\\IntellijProject\\Import***\\import****\\migrazione****-be\\pom.xml";
    JavaArchive pomFiles = ShrinkWrap.create(MavenImporter.class)
            .loadPomFromFile(str).importBuildOutput().as(JavaArchive.class);

/* https://github.com/shrinkwrap/resolver/blob/master/README.asciidoc#resolution-of-artifacts-defined-in-pom-files */
JavaArchive[] mistral_be = Maven.configureResolver().workOffline().resolve("it.****.mistral:mistral-be:0.1.0").withTransitivity().as(JavaArchive.class);

for (int i = 0; i < mistral_be.length ; i++) {
        pomFiles = pomFiles.merge(mistral_be[i]);

}

pomFiles.as(ZipExporter.class).exportTo(new File ("C:\\temp\\res.zip"));

它生成一个相当大的 zip 文件只是为了检查结果,但在尝试部署到 jboss 7.1.1 时

18:46:17,003 INFO  [org.jboss.as.repository] (management-handler-thread - 2) JBAS014900: Content added at location C:\jboss\jboss-as-7.1.1.Final\standalone\data\content\bc\b6fd502db2696342419c17a6d2ed82a4176a4e\content
18:46:17,008 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-8) JBAS015876: Starting deployment of "arquillian-service"

我有一个错误:

org.jboss.arquillian.container.spi.client.container.DeploymentException: Could not deploy to container: {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"postImportBE-1.0-SNAPSHOT.jar\".STRUCTURE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"postImportBE-1.0-SNAPSHOT.jar\".STRUCTURE: Failed to process phase STRUCTURE of deployment \"postImportBE-1.0-SNAPSHOT.jar\""}}

正如我在应用程序服务器日志中看到的那样

Caused by: java.lang.SecurityException: Invalid signature file digest for Manifest main attributes.

我在压缩文件目录的 META_INF 中看到很多文件来自 Mistra-be 的传递依赖项,所以问题可能是这样的。有没有办法生成带有有效签名的 JAR 文件?或者我可能使用了错误的方法来解决这个问题(以另一种方式构建jar或类似的想法)? 我很好奇为什么 pom 中存在依赖关系:

<dependency>
  <groupId>it.**.mistral</groupId>
    <artifactId>mistral-be</artifactId>
    <version>0.1.0</version>
    <scope>compile</scope>  
 </dependency>

不是直接用这条指令导入吗?我错过了什么吗?

String str = "C:\\IntellijProject\\Import***\\import****\\migrazione****-be\\pom.xml";
    JavaArchive pomFiles = ShrinkWrap.create(MavenImporter.class)
            .loadPomFromFile(str).importBuildOutput().as(JavaArchive.class);

谢谢

最佳答案

在处理 pom 依赖项时,我使用 WebArchive 而不是 JavaArchive 来包装 ShrinkWrap 生成的所有所需代码:

String[] mavenLibs = {
            "junit:junit:4.8.1"
};

WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war");
for (String dependency : mavenLibs) {
    war.addAsLibrary(Maven.resolver().resolve(dependency).withTransitivity().asSingle(JavaArchive.class));
}

使用这种机制,我没有遇到您所描述的问题。

关于java - pom 中的 Arquillian ShrinkWrap maven 依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26453160/

相关文章:

java - 如何测试 EJB 是否正在 JBoss AS 7 服务器上运行

java - 使用java中的scanner类从文件中获取输入

java - 构造函数的这两种用法之间有区别吗?

eclipse - : "Updating Maven Project". 不支持的 IClasspathEntry kind=4 期间发生内部错误

java - Vaadin 8 : Widgetset not compiling com. vaadin.terminal.gwt.DefaultWidgetSet 在项目中找不到

maven - Apache Maven 错误 : Could not transfer artifact org. apache.maven.plugins :maven-clean-plugin:pom: 2. 5 到中央

java - 有没有办法在java中确定应用程序服务器名称

java - 为什么在 Java 中初始化为 String.toString() 的 'final String' 不被视为常量

java - javafx ListView 中带有自定义 ListCell 的幽灵项目

java - JBoss MBean 通知监听器问题