Arquillian ShrinkWrap maven dependencies in pom

Since the proposal is on a different thread ( Arquillian ShrinkWrap switched to a managed container (Jboss AS 7.1), now the error is different

New dependency management (see previous link to original question)

<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>

      

Then I must add

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

      

Because I have Exception

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

      

And now deploying to a local Jboss instance is working fine (I will test with a simpler test as soon as I have little time, but I think everything is fine) Essentially the problem is adding the jar dependencies present in maven (mistral- be which is not part of this maven project) to the deployed test (see the description of this question ( Arquillian ShrinkWrap )). Finally i use this code

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"));

      

It generates a rather large zip file just to test the result, but for now try'n to deploy to 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"

      

I have an error:

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\""}}

      

As I can see in the application server log it is

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

      

I see many files in META_INF of zipped files directory coming from mistral-be transitive dependencies, so the problem might be like this. Is there a way to generate a JAR file with a valid signature? Or maybe I am using the wrong aprroach to solve this problem (contruct jar in a different way or a similar idea)? And I'm curious why the dependencies in the pom are:

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

      

not directly imported by this instruction? Did I miss something?

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

      

thank

+1


source to share


1 answer


When working with pom dependencies, I use WebArchive instead of JavaArchive to package all the required code generated by 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));
}

      



Using this mecanism, I didn't have the problem you described.

+1


source







All Articles