0 Replies Latest reply on Jan 31, 2018 1:37 PM by tiago.ventosa

    java.lang.IllegalStateException when doing full ear deploy

    tiago.ventosa

      Hello everyone,

       

      I've been playing around with arquillian to try and make tests for the application I'm currently working with. As the ear is pretty complex and has many dependencies, I'm trying to do a full deploy of the ear and launch tests from there. However I keep getting the following error right after the ear is deployed:

       

      17:36:11,125/GMT ERROR [stderr] (http-127.0.0.1:8080-4) java.lang.IllegalStateException: Service org.jboss.arquillian.junit.container.JUnitTestRunner does not implement expected type org.jboss.arquillian.container.test.spi.TestRunner

      17:36:11,126/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at org.jboss.arquillian.container.test.spi.util.ServiceLoader.createInstance(ServiceLoader.java:216)

      17:36:11,126/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at org.jboss.arquillian.container.test.spi.util.ServiceLoader.reload(ServiceLoader.java:181)

      17:36:11,126/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at org.jboss.arquillian.container.test.spi.util.ServiceLoader.getProviders(ServiceLoader.java:286)

      17:36:11,126/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at org.jboss.arquillian.container.test.spi.util.TestRunners.getTestRunner(TestRunners.java:57)

      17:36:11,126/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at org.jboss.arquillian.container.test.spi.util.TestRunners.getTestRunner(TestRunners.java:44)

      17:36:11,126/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.executeTest(ServletTestRunner.java:138)

      17:36:11,126/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.execute(ServletTestRunner.java:117)

      17:36:11,126/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.doGet(ServletTestRunner.java:86)

      17:36:11,126/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)

      17:36:11,126/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

      17:36:11,126/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)

      17:36:11,127/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)

      17:36:11,127/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231)

      17:36:11,127/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)

      17:36:11,127/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at org.jboss.modcluster.container.jbossweb.JBossWebContext$RequestListenerValve.event(JBossWebContext.java:91)

      17:36:11,127/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at org.jboss.modcluster.container.jbossweb.JBossWebContext$RequestListenerValve.invoke(JBossWebContext.java:72)

      17:36:11,127/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)

      17:36:11,128/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:150)

      17:36:11,128/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)

      17:36:11,128/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)

      17:36:11,128/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344)

      17:36:11,128/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at org.apache.coyote.http11.Http11NioProcessor.process(Http11NioProcessor.java:355)

      17:36:11,128/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:912)

      17:36:11,129/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at org.apache.tomcat.util.net.NioEndpoint$ChannelProcessor.run(NioEndpoint.java:936)

      17:36:11,129/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

      17:36:11,129/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

      17:36:11,129/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at org.apache.tomcat.util.net.NioEndpoint$DefaultThreadFactory$1$1.run(NioEndpoint.java:1249)

      17:36:11,129/GMT ERROR [stderr] (http-127.0.0.1:8080-4)        at java.lang.Thread.run(Thread.java:745)

       

      Then the code proceeds to undeploy, and fails the test with errors.

       

      My test class is still pretty simple:

       

      @RunWith(Arquillian.class)
      //@RunAsClient  //with this the test runs, but I need in-container tests
      public class ArquillianTest {
      
      private static EnterpriseArchive finalEar () {
      
      String earPath = "path/to/project/pom.xml"; //compiles jars, wars and the project ear
      
      
      BuiltProject builtProject = EmbeddedMaven
      .forProject(earPath)
      .useLocalInstallation()
      .setGoals("package")
      .setProfiles("arquillian-test-batch")
      .setOffline(true)
      .build();
      
      return builtProject.getModule("projectEar.ear").getDefaultBuiltArchive().as(EnterpriseArchive.class);
      }
      
      @Deployment
      public static Archive createDeployment() {
      
              EnterpriseArchive myEar = ShrinkWrap.create(EnterpriseArchive.class, "projectEar.ear")
              .merge(finalEar());
      
      
              Testable.archiveToTest(myEar.getAsType(WebArchive.class, "Flow-ServicesWS.war")
              .addClass(ArquillianTest.class));       
      
      
              return myEar;
          }
      
      
      @Test
      public void testDatabaseConnection() throws MalformedURLException, SQLException, Exception_Exception {
      
      }
      
      
      }

       

      the project maven pom (different from the ear pom) has the following dependencies (removed some internal project dependencies)

      EDIT: Was having some problems representing them with the xml syntax, so changed to quote

       

      <dependencyManagement>

          <dependencies>   

             <dependency>

       

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

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

            <version>3.0.0</version>

            <scope>import</scope>

            <type>pom</type>

          </dependency>

         

              <dependency>

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

                  <artifactId>arquillian-bom</artifactId>

                  <version>1.1.15.Final</version>

                  <scope>import</scope>

                  <type>pom</type>

              </dependency>

          </dependencies>

      </dependencyManagement>

       

       

      <dependencies>

       

      <dependency>

      <groupId>junit</groupId>

      <artifactId>junit</artifactId>

      <version>4.11</version>

      <scope>test</scope>

      </dependency>

       

      <dependency>

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

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

      <scope>test</scope>

      </dependency>

       

      <dependency>

          <groupId>org.jboss.as</groupId>

          <artifactId>jboss-as-arquillian-container-managed</artifactId>

          <version>7.2.0.Final</version>

      </dependency>

       

       

      <dependency>

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

      <artifactId>shrinkwrap-resolver-depchain</artifactId>

      <scope>test</scope>

      <type>pom</type>

      </dependency>

       

              <dependency>

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

                  <artifactId>arquillian-protocol-servlet</artifactId>

                  <scope>test</scope>

              </dependency>

       

      <dependency>

          <groupId>org.jboss.spec</groupId>

          <artifactId>jboss-javaee-6.0</artifactId>

          <version>3.0.3.Final</version>

          <type>pom</type>

          <scope>provided</scope>

      </dependency>

       

       

      <dependency>

      <groupId>javax</groupId>

      <artifactId>javaee-api</artifactId>

      <version>6.0</version>

      <scope>provided</scope>

      </dependency>

       

       

      <dependency>

      <groupId>org.hibernate</groupId>

      <artifactId>hibernate-core</artifactId>

      <version>4.2.6.Final</version>

      <scope>provided</scope>

      </dependency>

      </dependencies>

      and finally my arquillian.xml:

       

      <?xml version="1.0" encoding="UTF-8"?>
       <arquillian xmlns="http://jboss.org/schema/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">
         
          <defaultProtocol type="Servlet 3.0 />
          
          <engine>
            <property name="deploymentExportPath">target/deployments</property>
          </engine>
           
          
          <container qualifier="jbossas-managed" default="true">
             <configuration>
                <property name="serverConfig">standalone-full-ha-ldc-batch-LOCAL-ARQ.xml</property>
                <property name="jbossHome">C:\__ENV__\jboss_batch\EAP-6.4.0</property>
                <property name="outputToConsole">true</property>
                <property name="javaVmArguments">-Xms1G -Xmx1G -XX:MaxPermSize=256M</property>
             </configuration>
          </container
      </arquillian>
      
      

      The version of JBoss is JBoss EAP 6.4.7.GA, and java version 1.7.

       

      Not sure what else I can say that could help. From searching for solutions to this problem I couldn't find anything similar.

       

      From checking the source code where the exception was thrown, it's actually a ClassCastException. From my clueless research I read that this could happen when the classes are loaded from different class loaders, but no idea if this is the case. indeed in the code it is easy to check that JUnitTestRunner indeed implements TestRunner, contrary to the exception message.

       

      Anyone knows what I could do to go around this problem? Or how to fix it?