3

I am deploying a war into JBoss 7.x using Arquillian for testing and it has a dependency on Apache Commons Collections. However, it just doesn't seem to pick up the module dependency.

MANIFEST.MF

Dependencies: org.apache.commons.collectionss export

Arquillian Deployment

@Deployment
public static Archive<?> createDeployment() {
    WebArchive archive = ShrinkWrap.create(WebArchive.class);

    archive
        .addPackages(true, "com.example.package")
        .addAsResource("META-INF/MANIFEST.MF", "META-INF/MANIFEST.MF")

      // * Tried the following two options with no luck
      //.AddAsManifestResource("META-INF/MANIFEST.MF", "MANIFEST.MF")
      //.AddAsWebInfResource("META-INF/MANIFEST.MF", "META-INF/MANIFEST.MF")

      // * If I enable the following, it works fine. getLibrary just picks
      // * up the lib through maven.
      //.addAsLibraries(
      //         getLibrary("commons-collections:commons-collections:3.2.1"))
       ;

    return archive;
}

I don't want to use jboss-deployment-structure.xml since it feels like using a sledgehammer to crack a nut.

Any ideas?

drone.ah
  • 1,135
  • 14
  • 28
  • Maybe just a typo on here, but there is an extra `s` in your module name. Also is there a reason you don't just bundle it with your application? – James R. Perkins Apr 11 '13 at 20:21
  • just a typo I'm afraid. I tried it with that just now to see if it errors out - which it doesn't suggesting that the file is not even read. I am bundling it as a workaround but prefer to not bundle libraries already provided by the AppServer – drone.ah Apr 12 '13 at 08:24
  • For some libraries you probably want to. In the modules.xml it's marked as `` which means in the future you might need to bundle it anyway. – James R. Perkins Apr 12 '13 at 22:24
  • 1
    OP: does the provided answer help you? – MartinTeeVarga Jun 11 '13 at 04:14

2 Answers2

5

In my case I added a MANIFEST.MF within src/test/resources and .addAsManifestResource("MANIFEST.MF") for Arquillian

MANIFEST.MF

Manifest-Version: 1.0
Built-By: me
Build-Jdk: 1.6.0_45 
Created-By: Maven Integration for Eclipse
Dependencies: org.infinispan export

Arquillian

@Deployment(testable = false)
public static WebArchive createDeployment() {
    MavenDependencyResolver mvnResolver = DependencyResolvers.use(MavenDependencyResolver.class).loadMetadataFromPom("pom.xml").goOffline();

    return ShrinkWrap
            .create(WebArchive.class, "example.war")
            .addPackages(true, Filters.exclude(".*Test.*"), "com/comapany/")
            .addAsManifestResource("MANIFEST.MF")
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
    }
}
Tobias Sarnow
  • 1,076
  • 2
  • 12
  • 40
  • I tried this... and the file gets added correctly as far as I can tell. However, the dependency is not getting picked up. If I make the modules global, it works fine... but then the dependencies line has no effect... – drone.ah Dec 12 '13 at 11:32
  • Works like a charm with the private apache http modules on 7.3 – Heiner Dec 09 '21 at 20:18
0

As it turned out, I asked this same question again (this time about Jar Files) since I forgot all about this question.

The solution has also since been discovered: (Same as from the other question)

The whole thing turned out to be a lot simpler.

Even with .addAsManifestResource OR .setManifest, the MANIFEST.MF was autogenerated by Maven.

This was resolved with the following section in pom.xml instead of using a custom MANIFEST.MF and using .setManifest("META-INF/MANIFEST.MF"); The MANIFEST.MF is auto-generated and there is no customised copy in the resources folder (to avoid confusion more than anything since it was ignored anyway)

<build>
    <plugins>
     <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-war-plugin</artifactId>
       <configuration>
          <archive>
             <manifestEntries>
                <Dependencies>
                org.infinispan, 
                org.infinispan.infinispan-tree export,
                </Dependencies>
             </manifestEntries>
          </archive>
       </configuration>
     </plugin>
    </plugins>
</build>
Community
  • 1
  • 1
drone.ah
  • 1,135
  • 14
  • 28