1 Reply Latest reply on Jan 23, 2013 9:13 AM by Karel Piwko

    Deployment failure with arquillian-tomcat-embedded-7 1.0.0.CR4 and Arquillian 1.0.3.Final

    Gregory Levilain Newbie

      I get this failure : IllegalArgumentException: Instance must be specified

      while deploying my archive into Tomcat 7 Embedded. (full stack trace below)

       

      (My test is green if using the arquillian-glassfish-3.1-embedded profile)

       

      Any help appreciated.

       

      pom.xml

          <dependencyManagement>

              <dependencies>

                  <dependency>

                      <groupId>org.jboss.shrinkwrap.resolver</groupId>

                      <artifactId>shrinkwrap-resolver-bom</artifactId>

                      <version>2.0.0-alpha-6</version>

                      <scope>import</scope>

                      <type>pom</type>

                  </dependency>

                  <dependency>

                      <groupId>org.jboss.arquillian</groupId>

                      <artifactId>arquillian-bom</artifactId>

                      <version>1.0.3.Final</version>

                      <scope>import</scope>

                      <type>pom</type>

                  </dependency>

              </dependencies>

          </dependencyManagement>

          [...]

              <!-- Arquillian test automation -->

              <dependency>

                  <groupId>org.jboss.arquillian.junit</groupId>

                  <artifactId>arquillian-junit-container</artifactId>

                  <scope>test</scope>

              </dependency>

              <!-- Add ShrinkWrap support for resolution of maven artifacts and addition of dependencies into the test WAR archive using

                  Maven. -->

              <dependency>

                  <groupId>org.jboss.shrinkwrap.resolver</groupId>

                  <artifactId>shrinkwrap-resolver-impl-maven</artifactId>

                  <scope>test</scope>

              </dependency>

          [...]

       

              <profile>

                  <id>arquillian-glassfish-3.1-embedded</id>

                  <dependencies>

                      <!-- GlassFish Embedded 3.1 arquillian adapter. -->

                      <dependency>

                          <groupId>org.jboss.arquillian.container</groupId>

                          <artifactId>arquillian-glassfish-embedded-3.1</artifactId>

                          <version>1.0.0.CR3</version>

                          <scope>test</scope>

                      </dependency>

                      <dependency>

                          <groupId>org.glassfish.main.extras</groupId>

                          <artifactId>glassfish-embedded-all</artifactId>

                          <version>3.1.2</version>

                          <scope>provided</scope>

                      </dependency>

                  </dependencies>

              </profile>

              <profile>

                  <id>arquillian-tomcat-7.0-embedded</id>

                  <activation>

                      <activeByDefault>true</activeByDefault>

                  </activation>

                  <dependencies>

                      <!-- Tomcat Embedded 7.0 arquillian adapter. -->

                      <dependency>

                          <groupId>org.jboss.arquillian.container</groupId>

                          <artifactId>arquillian-tomcat-embedded-7</artifactId>

                          <version>1.0.0.CR4</version>

                          <scope>test</scope>

                      </dependency>

                      <dependency>

                          <groupId>org.apache.tomcat.embed</groupId>

                          <artifactId>tomcat-embed-core</artifactId>

                          <version>7.0.34</version>

                          <scope>provided</scope>

                      </dependency>

                      <dependency>

                          <groupId>org.apache.tomcat.embed</groupId>

                          <artifactId>tomcat-embed-jasper</artifactId>

                          <version>7.0.34</version>

                          <scope>provided</scope>

                      </dependency>

                      <dependency>

                          <groupId>org.apache.tomcat.embed</groupId>

                          <artifactId>tomcat-embed-logging-juli</artifactId>

                          <version>7.0.34</version>

                          <scope>provided</scope>

                      </dependency>

                      <dependency>

                          <groupId>org.eclipse.jdt.core.compiler</groupId>

                          <artifactId>ecj</artifactId>

                          <version>3.7</version>

                          <scope>test</scope>

                      </dependency>

                  </dependencies>

              </profile>

       

      ArquillianTest.java:

      package org.demo.packager;

       

      import static com.jayway.restassured.RestAssured.*;

      import static org.junit.Assert.*;

       

      import java.io.File;

       

      import org.jboss.arquillian.container.test.api.Deployment;

      import org.jboss.arquillian.container.test.api.RunAsClient;

      import org.jboss.arquillian.junit.Arquillian;

      import org.jboss.shrinkwrap.api.ArchivePath;

      import org.jboss.shrinkwrap.api.ArchivePaths;

      import org.jboss.shrinkwrap.api.ShrinkWrap;

      import org.jboss.shrinkwrap.api.spec.WebArchive;

      import org.jboss.shrinkwrap.resolver.api.maven.Maven;

      import org.junit.Test;

      import org.junit.runner.RunWith;

       

      import com.jayway.restassured.response.Response;

       

      @RunWith(Arquillian.class)

      public class ArquillianTest {

       

          @Deployment

          public static WebArchive createDeployment() {

       

              File[] libs = Maven.resolver().loadPomFromFile("pom.xml").importRuntimeDependencies().asFile();

              File SRC_MAIN_WEBAPP = new File("src/main/webapp");

              File SRC_MAIN_RESOURCES = new File("src/main/resources");

       

              WebArchive war = ShrinkWrap.create(WebArchive.class, "Packager");

              war.addPackages(true, "org.demo.packager");

              war.addAsLibraries(libs);

              addFiles(war, SRC_MAIN_WEBAPP, ArquillianResourceType.WEB_RESOURCES);

              addFiles(war, SRC_MAIN_RESOURCES, "WEB-INF/classes", ArquillianResourceType.RESOURCES);

       

              System.out.println(war.toString(true));

              return war;

          }

       

          private enum ArquillianResourceType {

              RESOURCES, WEB_RESOURCES;

          }

       

          private static void addFiles(WebArchive war, File dir, ArquillianResourceType resourceType) {

              addFiles(war, dir, "", resourceType);

          }

       

          private static void addFiles(WebArchive war, File dir, String context, ArquillianResourceType resourceType) {

              addFiles(war, dir, ArchivePaths.create(context), resourceType);

          }

       

          private static void addFiles(WebArchive war, File dir, ArchivePath context, ArquillianResourceType resourceType) {

              if (!dir.isDirectory()) {

                  throw new RuntimeException(dir.getAbsolutePath() + " is not a directory");

              }

              for (File f : dir.listFiles()) {

                  if (f.isFile()) {

                      ArchivePath fileContext = ArchivePaths.create(context, f.getName());

                      switch (resourceType) {

                      case RESOURCES:

                          war.addAsResource(f, fileContext);

                          break;

                      case WEB_RESOURCES:

                          war.addAsWebResource(f, fileContext);

                          break;

                      }

                  } else {

                      addFiles(war, f, ArchivePaths.create(context, f.getName()), resourceType);

                  }

              }

          }

       

          @Test

          @RunAsClient

          public void test() {

              Response response =

                      given().header("Content-Type", "application/json; charset=utf-8")

                              .header("Accept", "application/json")

                              .body("{\"address\":\"Réunion\",\"clientId\":\"create123\",\"firstName\":\"Greg\",\"lastName\":\"Levilain\"}")

                              .then().post("http://localhost:8181/Packager/clients").andReturn();

       

              assertEquals(201, response.getStatusCode());

          }

       

      }

       

      Full stack trace:

      org.jboss.arquillian.container.spi.client.container.DeploymentException: Failed to deploy Packager

          at org.jboss.arquillian.container.tomcat.embedded_7.TomcatContainer.deploy(TomcatContainer.java:227)

          at org.jboss.arquillian.container.impl.client.container.ContainerDeployController$3.call(ContainerDeployController.java:161)

          at org.jboss.arquillian.container.impl.client.container.ContainerDeployController$3.call(ContainerDeployController.java:128)

          at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.executeOperation(ContainerDeployController.java:271)

          at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.deploy(ContainerDeployController.java:127)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

          at org.jboss.arquillian.container.impl.client.container.DeploymentExceptionHandler.verifyExpectedExceptionDuringDeploy(DeploymentExceptionHandler.java:50)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

          at org.jboss.arquillian.container.impl.client.ContainerDeploymentContextHandler.createDeploymentContext(ContainerDeploymentContextHandler.java:78)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

          at org.jboss.arquillian.container.impl.client.ContainerDeploymentContextHandler.createContainerContext(ContainerDeploymentContextHandler.java:57)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)

          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)

          at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)

          at org.jboss.arquillian.container.impl.client.container.ContainerDeployController$1.perform(ContainerDeployController.java:95)

          at org.jboss.arquillian.container.impl.client.container.ContainerDeployController$1.perform(ContainerDeployController.java:80)

          at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.forEachDeployment(ContainerDeployController.java:263)

          at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.forEachManagedDeployment(ContainerDeployController.java:239)

          at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.deployManaged(ContainerDeployController.java:79)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)

          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)

          at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)

          at org.jboss.arquillian.container.test.impl.client.ContainerEventController.execute(ContainerEventController.java:101)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

          at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

          at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)

          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)

          at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:80)

          at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:182)

          at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)

          at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)

          at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:199)

          at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

          at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)

          at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

          at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

      Caused by: java.lang.IllegalArgumentException: Instance must be specified

          at org.jboss.arquillian.core.spi.Validate.notNull(Validate.java:44)

          at org.jboss.arquillian.core.impl.ManagerImpl.bind(ManagerImpl.java:164)

          at org.jboss.arquillian.core.impl.ManagerImpl.bindAndFire(ManagerImpl.java:235)

          at org.jboss.arquillian.core.impl.InstanceImpl.set(InstanceImpl.java:74)

          at org.jboss.arquillian.container.tomcat.embedded_7.TomcatContainer.deploy(TomcatContainer.java:213)

          ... 87 more