Arquillian: Create a WebArchive from an existing war using ShrinkWrap

cbeaudin picture cbeaudin · Jul 23, 2013 · Viewed 8.9k times · Source

I am trying to deploy an existing war from another maven project in Arquillian. I have resolved the war and have it copied to the target directory of my Arquillian project.

I try to create it below:

@Deployment
public static WebArchive createDeployment() {

    return (WebArchive) ShrinkWrap.create(ZipImporter.class, "MyWarToTest.war").importFrom(
            new File("target/MyWarToTest.war"));

}

However, I am getting a class cast exception.

Caused by: java.lang.ClassCastException: org.jboss.shrinkwrap.impl.base.importer.zip.ZipImporterImpl cannot be cast to org.jboss.shrinkwrap.api.Archive

I am guessing that I should be trying to create the war a different way?

Answer

Henk de Vries picture Henk de Vries · Dec 6, 2013

Adding my 2 cents. Even more quick (and with the same result) is the following method:

@Deployment
public static WebArchive createDeployment() {
    return ShrinkWrap.createFromZipFile(WebArchive.class, new File("target/payloadPlan.war"));
}