1 Reply Latest reply on Dec 30, 2015 11:10 PM by Ben Han

    Add dependency to a war archive by ShrinkWrap 1.1.2+ShrinkWrap Resolver 2.0.0

    Ben Han Newbie

      Hi,

       

      I am running a test case using ShrinkWrap packaging a war. I need ass some dependencies into the war which will be deployed on WildFly AS 10.

      The test case follows:

       

      @RunWith(Arquillian.class)

      public abstract class AbstractWCITestCase

      {

         protected static WebArchive wciJBoss7Deployment(String name)

         {

            WebArchive war = name != null ? ShrinkWrap.create(WebArchive.class, name) : ShrinkWrap.create(WebArchive.class);

            war.addAsResource("META-INF/services/org.jboss.msc.service.ServiceActivator");

            File[] files = Maven.resolver().loadPomFromFile("../pom.xml")

                                          .importDependencies(ScopeType.COMPILE, ScopeType.TEST, ScopeType.PROVIDED, ScopeType.RUNTIME)

                                          .resolve().withTransitivity().asFile();

            if(files != null){

                war.addAsLibraries(files);

            }

            war.addClass(AbstractWCITestCase.class);

            return war;

         }

      ...

       

      All works fine except running to the bold line in source code above, this line tries to read a pom.xml and import all the dependencies define in it. The full stack tracing is below:

      java.lang.RuntimeException: Could not invoke deployment method: public static org.jboss.shrinkwrap.api.spec.WebArchive org.gatein.wci.test.jboss7.deployment.DeploymentTestCase.wciDeployment()

        at org.jboss.shrinkwrap.resolver.impl.maven.util.Validate.notEmpty(Validate.java:78)

        at org.jboss.shrinkwrap.resolver.impl.maven.MavenStrategyStageBaseImpl.using(MavenStrategyStageBaseImpl.java:65)

        at org.jboss.shrinkwrap.resolver.impl.maven.MavenStrategyStageBaseImpl.withTransitivity(MavenStrategyStageBaseImpl.java:49)

        at org.jboss.shrinkwrap.resolver.impl.maven.MavenStrategyStageBaseImpl.withTransitivity(MavenStrategyStageBaseImpl.java:38)

        at org.gatein.wci.test.AbstractWCITestCase.wciJBoss7Deployment(AbstractWCITestCase.java:45)

        at org.gatein.wci.test.jboss7.deployment.DeploymentTestCase.wciDeployment(DeploymentTestCase.java:34)

       

      If I don't try to add dependencies to war, a class defined in the same project can not be found, stack tracing below:

      Caused by: java.lang.Exception: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"deploymentwci.war\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"deploymentwci.war\".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment \"deploymentwci.war\"

          Caused by: java.util.ServiceConfigurationError: org.jboss.msc.service.ServiceActivator: Provider org.gatein.wci.wildfly.GateInWCIServiceActivator not found"}}

       

      I am using ShrinkWrap 1.1.2 and ShrinkWrap resolver 2.0.0.

      Can anyone help me?

      Thanks.