10 Replies Latest reply on May 28, 2014 5:31 PM by Robert Panzer

    Test ClassNotFound or Could not start container

    Denys S. Newbie

      I'm running integration tests on Linux platform using glassfish 3.1. When using an embedded glassfish server everything works perfectly. However when switching to either remote or managed glassfish I'm getting two completely different exceptions.

       

      arquillian.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <arquillian xmlns="http://jboss.com/arquillian"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="
                    http://jboss.org/schema/arquillian
                    http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
        <engine>
          <property name="deploymentExportPath">target/arquillian</property>
        </engine>
      <!--  <container qualifier="glassfish-remote" default="true">
          <configuration>
            <property name="adminHost">${glassfish.hostname}</property>
            <property name="adminUser">${glassfish.username}</property>
            <property name="adminPassword">admin</property>
            <property name="adminPort">${glassfish.adminport}</property>
          </configuration>
        </container>-->
        <container qualifier="glassfish-managed" default="true">
          <configuration>
            <property name="glassFishHome">/ws/appservers/glassfish</property>
            <property name="adminHost">localhost</property>
            <property name="adminPort">7048</property>
            <property name="adminUser">admin</property>
            <property name="adminPassword">admin</property>
          </configuration>
        </container>
      <!--  <container default="true" qualifier="glassfish-embedded">
          <configuration>
            <property name="bindHttpPort">${gf3port}</property>
            <property name="resourcesXml">${gf.resources.file}</property>
          </configuration>
        </container>-->
      </arquillian>
      
      


      With dependencies in pom (only most important are highlighted):

      <!-- Container dependencies -->
         <dependency>
         <groupId>org.jboss.arquillian.container</groupId>
         <artifactId>arquillian-glassfish-remote-3.1</artifactId>
         <version>1.0.0.CR4</version>
         <scope>test</scope>
         </dependency>
      <!--
      
         <dependency>
         <groupId>org.jboss.arquillian.container</groupId>
         <artifactId>arquillian-glassfish-managed-3.1</artifactId>
         <version>1.0.0.CR4</version>
         <scope>test</scope>
         </dependency>
      -->
         <dependency>  
         <groupId>org.jboss.spec</groupId>  
         <artifactId>jboss-javaee-6.0</artifactId>  
         <version>1.0.0.Final</version>  
         <type>pom</type>  
         <scope>provided</scope>  
         </dependency>
      
         <dependency>
         <groupId>org.jboss.arquillian.extension</groupId>
         <artifactId>arquillian-persistence-api</artifactId>   
         </dependency>
         <dependency>
         <groupId>org.jboss.arquillian.extension</groupId>
         <artifactId>arquillian-persistence-impl</artifactId>
         <scope>compile</scope>
         </dependency>
         <dependency>
         <groupId>org.jboss.shrinkwrap.resolver</groupId>
         <artifactId>shrinkwrap-resolver-depchain</artifactId>
         <type>pom</type>
         <scope>test</scope>
         </dependency>
      
      


      Stack trace of the managed trial:

      Running service.repository.PaaSummarylFilterIT
      Configuring TestNG with: TestNG652Configurator
      Tests run: 5, Failures: 1, Errors: 0, Skipped: 4, Time elapsed: 2.617 sec <<< FAILURE! - in service.repository.PaaSummarylFilterIT
      arquillianBeforeSuite(service.repository.PaaSummarylFilterIT)  Time elapsed: 2.546 sec  <<< FAILURE!
      org.jboss.arquillian.container.spi.client.container.LifecycleException: Could not start container
        at org.jboss.arquillian.container.glassfish.managed_3_1.GlassFishServerControl.start(GlassFishServerControl.java:53)
        at org.jboss.arquillian.container.glassfish.managed_3_1.GlassFishManagedDeployableContainer.start(GlassFishManagedDeployableContainer.java:79)
        at org.jboss.arquillian.container.impl.ContainerImpl.start(ContainerImpl.java:199)
      


      Stacktrace of the remote trial:

      Running service.repository.PaaSummarylFilterIT
      Configuring TestNG with: TestNG652Configurator
      Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 13.41 sec <<< FAILURE! - in service.repository.PaaSummarylFilterIT
      testList2(service.repository.PaaSummarylFilterIT)  Time elapsed: 0.059 sec  <<< FAILURE!
      java.lang.ClassNotFoundException: service.repository.PaaSummarylFilterIT
        at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1509)
        at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)
        at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.executeTest(ServletTestRunner.java:158)
        at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.execute(ServletTestRunner.java:126)
        at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.doGet(ServletTestRunner.java:90)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
        at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
        at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)

       

       

      Server log is not informative, since nothing related to the problem is displayed there. Any ideas what could have gone wrong or where one should look for possible solution?

        • 1. Re: Test ClassNotFound or Could not start container
          Bartosz Majsak Master

          Can you share your test class? Most likely @Deployment method is incomplete. You can inspect what's package in your deployment either by simply printing it out archive.toString(true) or check the file which was exported to the arbitrary location which you defined in your arquillian.xml

             <engine>

              <property name="deploymentExportPath">target/deployment</property>

            </engine>

          • 2. Re: Re: Test ClassNotFound or Could not start container
            Denys S. Newbie

            That is not the case. I've compared the contents of the ear we deploy as a standalone deployment and the one generated in arquillian by the deployment method, they have identically the same contents. If to compare the resulting .ear the one generated by arquillian also has some additional test.war and couple of arquillian libs which is what enrichment is all about, afaik. However the error is still there. I'm talking about remote deployment.

             

            The test is extremely simple and looks as follows:

             

            @Slf4j
            public class PaaSummarylFilterIT extends BaseArquillian {
                @Test
                @Transactional(TransactionMode.ROLLBACK)
                public void testList2() {
                    System.out.print("This is an empty test");
                }
            }
            
            

             

            BaseArquillian has the deployment method.

            • 3. Re: Test ClassNotFound or Could not start container
              Bartosz Majsak Master

              Can I see complete logs? Maybe there is some hint hidden in there.

              • 4. Re: Re: Test ClassNotFound or Could not start container
                Denys S. Newbie

                Sure:

                Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 13.345 sec <<< FAILURE! - in service.repository.PaaSummarylFilterIT
                testList2(service.repository.PaaSummarylFilterIT)  Time elapsed: 0.06 sec  <<< FAILURE!
                java.lang.ClassNotFoundException: service.repository.PaaSummarylFilterIT
                  at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1509)
                  at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)
                  at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.executeTest(ServletTestRunner.java:158)
                  at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.execute(ServletTestRunner.java:126)
                  at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.doGet(ServletTestRunner.java:90)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
                  at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
                  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
                  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                  at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
                  at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
                  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
                  at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
                  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
                  at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
                  at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
                  at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
                  at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
                  at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
                  at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
                  at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
                  at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
                  at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
                  at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
                  at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
                  at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
                  at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
                  at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
                  at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
                  at java.lang.Thread.run(Thread.java:744)
                
                Results :
                Failed tests:
                  PaaSummarylFilterIT.testList2 » ClassNotFoundservice.repository.PaaSum...
                
                
                Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
                

                 

                That's pretty much it, since in the server log there's nothing related to this issue, neither errors nor warnings.

                • 5. Re: Test ClassNotFound or Could not start container
                  Bartosz Majsak Master

                  Well it's not that helpful Damn logs

                  Can you somehow share the project (or excerpt of it), let's say through GitHub, so I can analyze the running code and send the pull request if I find anything?

                  • 6. Re: Test ClassNotFound or Could not start container
                    Robert Panzer Newbie

                    Hi,

                     

                    in which archive did you add the test class?

                    In ears the test class is not automatically added to the deployment but you have to do it yourself in the @Deployment method.

                     

                    Kind regards

                    Robert

                    • 7. Re: Test ClassNotFound or Could not start container
                      Denys S. Newbie

                      Hi Robert,

                       

                      Can you provide any reference to back up your statement? AFAIK arquillian enriches the ear with certain custom stuff to run the tests. In my specific example I can find a new test.war file inside the .ear which has some arquillian-protocol.jar lib. However that is the only difference between my ear and the custom arquillian ear, at which point your argument seems to make sense if one expects the tests to be run within the container.

                      • 8. Re: Test ClassNotFound or Could not start container
                        Robert Panzer Newbie

                        Hi Denys,

                         

                        the test.war contains the ArquillianServletRunner that is called by arquillian on the client side to trigger execution of the test methods.

                        Therefore the servlet must be able to load the test class and that means that it must be visible to exactly this test.war.

                         

                        I haven't seen an explicit statement in the documentation yet and the book "Continuous Enterprise Development" in Java also does not go into details here, but I am pretty sure that you have to add the test class yourself to the ear. For example you could add a JavaArchive as a Library to the ear that contains your test case and all dependent test classes.

                        Or what I sometimes do is add a WebArchive myself to the ear containing the test class. Arquillian will pick that war and add the ArquillianServletRunner to this war.

                         

                        If your @Deployment is a WebArchive Arquillian will slyly add the test class to the war. That's why you probably never see this in the examples.

                         

                        Kind regards,

                        Robert

                        • 9. Re: Test ClassNotFound or Could not start container
                          Denys S. Newbie

                          And how can you explain that this ear that I was generating without test classes still executes all tests in embedded glassfish but not in the remote one?

                          • 10. Re: Test ClassNotFound or Could not start container
                            Robert Panzer Newbie

                            In embedded mode the server is running in the same process the test case is already running in.

                            So usually the server is loaded and running by the same ClassLoader as the test case.

                            Therefore it is available under all circumstances.

                             

                            That's why even with ShrinkWrap you can get into ClassLoader hell in embedded mode because every class is visible that is in the test class path, plus the classes collected by ShrinkWrap.

                             

                            Embedded mode is fast, but it is also a little bit dangerous because you might "see" classes that you did not package in your @Deployment.

                             

                            Kind regards,

                            Robert