1 Reply Latest reply on May 9, 2010 5:46 PM by Andrew Rubinger

    Environment-Specific Error in container-glassfish-embedded-30

    Andrew Rubinger Master

      My environment reliably gets this error in the new GFv3 Embedded integration test for ARQ:

       

      java.io.FileNotFoundException: http://localhost:8080/test/Test
          at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1303)
          at java.net.URL.openStream(URL.java:1009)
          at org.jboss.arquillian.glassfish.GlassFishEmbeddedContainerTestCase.shouldBeAbleToDeployWebArchive(GlassFishEmbeddedContainerTestCase.java:68)
          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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
          at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
          at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
          at org.jboss.arquillian.junit.Arquillian$6$1.invoke(Arquillian.java:202)
          at org.jboss.arquillian.impl.handler.ActivateRunModeTypeLocal$LocalMethodExecutor.invoke(ActivateRunModeTypeLocal.java:59)
          at org.jboss.arquillian.impl.handler.ContainerTestExecuter.callback(ContainerTestExecuter.java:50)
          at org.jboss.arquillian.impl.handler.ContainerTestExecuter.callback(ContainerTestExecuter.java:40)
          at org.jboss.arquillian.impl.event.MapEventManager.fire(MapEventManager.java:63)
          at org.jboss.arquillian.impl.context.AbstractEventContext.fire(AbstractEventContext.java:115)
          at org.jboss.arquillian.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:117)
          at org.jboss.arquillian.junit.Arquillian$6.evaluate(Arquillian.java:197)
          at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
          at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:169)
          at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
          at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:183)
          at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
          at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:44)
          at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
          at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
          at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
          at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
          at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:139)
          at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
          at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:153)
          at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
          at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:105)
          at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
          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)

       

      This isn't present in my Hudson environment.

       

      The output shows the application getting loaded, so I don't know what's up.  The test fails and it also 404s from a browser.

       

      May 9, 2010 3:50:22 PM com.sun.enterprise.web.WebApplication start
      INFO: Loading application test at /test

       

      BTW straight URL connections to a servlet are more brittle than using Apache's HttpClient for example.  That's not the root of the error in this case (I verified manually).

       

      Additionally, I think we can make the test more integration-centric if it uses the ARQ annotations etc:

       

      [alr@localhost trunk]$ svn di containers/glassfish-embedded-30/
      Index: containers/glassfish-embedded-30/src/test/java/org/jboss/arquillian/glassfish/GlassFishEmbeddedContainerTestCase.java
      ===================================================================
      --- containers/glassfish-embedded-30/src/test/java/org/jboss/arquillian/glassfish/GlassFishEmbeddedContainerTestCase.java    (revision 4375)
      +++ containers/glassfish-embedded-30/src/test/java/org/jboss/arquillian/glassfish/GlassFishEmbeddedContainerTestCase.java    (working copy)
      @@ -19,50 +19,49 @@
       import java.io.ByteArrayOutputStream;
       import java.io.InputStream;
       import java.net.URL;
      +import java.util.logging.Logger;
       
      -import org.jboss.arquillian.impl.DynamicServiceLoader;
      -import org.jboss.arquillian.impl.XmlConfigurationBuilder;
      -import org.jboss.arquillian.impl.context.SuiteContext;
      -import org.jboss.arquillian.spi.Context;
      -import org.jboss.arquillian.spi.DeployableContainer;
      +import org.jboss.arquillian.api.Deployment;
      +import org.jboss.arquillian.api.RunMode;
      +import org.jboss.arquillian.api.RunModeType;
      +import org.jboss.arquillian.junit.Arquillian;
       import org.jboss.shrinkwrap.api.ShrinkWrap;
       import org.jboss.shrinkwrap.api.spec.WebArchive;
      -import org.junit.After;
       import org.junit.Assert;
      -import org.junit.Before;
       import org.junit.Test;
      +import org.junit.runner.RunWith;
       
      +
       /**
        * GlassFishEmbeddedContainerTestCase
        *
        * @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a>
        * @version $Revision: $
        */
      +@RunWith(Arquillian.class)
      +@RunMode(RunModeType.LOCAL)
       public class GlassFishEmbeddedContainerTestCase 
       {
      -   private DeployableContainer container;
      -   
      -   private Context context = new SuiteContext(new DynamicServiceLoader());
      -   
      -   private WebArchive war = ShrinkWrap.create("test.war", WebArchive.class)
      -                              .addClass(TestServlet.class);
       
      -   @Before
      -   public void startup() throws Exception
      +   /**
      +    * Logger
      +    */
      +   private static final Logger log = Logger.getLogger(GlassFishEmbeddedContainerTestCase.class.getName());
      +   
      +   /**
      +    * Deployment for the test
      +    * @return
      +    */
      +   @Deployment
      +   public static WebArchive getDeployment()
          {
      -      container = new GlassFishEmbeddedContainer();
      -      container.setup(context, new XmlConfigurationBuilder().build());
      -      container.start(context);
      -      container.deploy(context, war);
      -   }
      +      final WebArchive war = ShrinkWrap.create("test.war", WebArchive.class).addClass(TestServlet.class);
      +      log.info(war.toString(true));
      +      return war;
       
      -   @After
      -   public void shutdown() throws Exception
      -   {
      -      container.undeploy(context, war);
      -      container.stop(context);
          }
       
      +
          @Test
          public void shouldBeAbleToDeployWebArchive() throws Exception
          {
      Index: containers/glassfish-embedded-30/pom.xml
      ===================================================================
      --- containers/glassfish-embedded-30/pom.xml    (revision 4375)
      +++ containers/glassfish-embedded-30/pom.xml    (working copy)
      @@ -97,6 +97,13 @@
                <version>${project.version}</version>
                <scope>test</scope>
             </dependency>
      +      
      +      <dependency>
      +        <groupId>org.jboss.arquillian</groupId>
      +        <artifactId>arquillian-junit</artifactId>
      +        <version>${project.version}</version>
      +        <scope>test</scope>
      +      </dependency>
       
             <dependency>
                <groupId>junit</groupId>