5 Replies Latest reply on Aug 1, 2015 9:10 PM by raneves

    tomcat-embedded-7 error during maven build: org.apache.catalina.util.ContextName.<init>(Ljava/lang/String;Z)V

    raneves

      Hi people.

      My arquillian.xml is:

      <?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" />
          <extension qualifier="spring-deployer">
              <!-- Disable loading pom dependencies -->
              <property name="importPomDependencies">false</property>
          </extension>
          <extension qualifier="spring">
          </extension>
          <engine>
              <property name="deploymentExportPath">target</property>
          </engine>
          <container qualifier="tomcat" default="true">
              <configuration>
                  <property name="tomcatHome">target/tomcat-embedded-7</property>
                  <property name="workDir">work</property>
                  <property name="appBase">webapps</property>
                  <property name="bindHttpPort">8080</property>
                  <property name="unpackArchive">true</property>
                  <property name="serverName">arquillian-tomcat-embedded-7</property>
              </configuration>
          </container>
      </arquillian>
      
      
      

       

      my pom.xml (I did not create a profile, because I believe it not necessary)

      <!--  Arquillian Depencies-->
              <dependency>
                  <groupId>org.jboss.arquillian.junit</groupId>
                  <artifactId>arquillian-junit-container</artifactId>
                  <version>1.1.5.Final</version>
              </dependency>
      
              <dependency>
                  <groupId>org.jboss.arquillian.protocol</groupId>
                  <artifactId>arquillian-protocol-servlet</artifactId>
                  <version>1.1.7.Final</version>
                  <scope>test</scope>
              </dependency>
      
              <dependency>
                  <groupId>org.jboss.arquillian.container</groupId>
                  <artifactId>arquillian-tomcat-embedded-7</artifactId>
                  <version>1.0.0.CR7</version>
                  <scope>test</scope>
              </dependency>
              <dependency>
                  <groupId>org.apache.tomcat.embed</groupId>
                  <artifactId>tomcat-embed-core</artifactId>
                  <version>7.0.29</version>
                  <scope>provided</scope>
              </dependency>
      
              <dependency>
                  <groupId>org.apache.tomcat.embed</groupId>
                  <artifactId>tomcat-embed-jasper</artifactId>
                  <version>7.0.29</version>
                  <scope>provided</scope>
              </dependency>
              <dependency>
                  <groupId>org.apache.tomcat.embed</groupId>
                  <artifactId>tomcat-embed-logging-juli</artifactId>
                  <version>7.0.29</version>
                  <scope>provided</scope>
              </dependency>
      
      
      

       

      only add this dependencies based on documentation. I don't created a profile.

       

      I need test of my REST API, so it is a integration test for rest api.

      My class of test is:

      package com.acme.ac.api;
      
      import static org.junit.Assert.assertNotNull;
      
      import java.net.URL;
      
      import org.codehaus.jackson.map.ObjectMapper;
      import org.jboss.arquillian.container.test.api.Deployment;
      import org.jboss.arquillian.container.test.api.OverProtocol;
      import org.jboss.arquillian.container.test.api.RunAsClient;
      import org.jboss.arquillian.junit.Arquillian;
      import org.jboss.arquillian.test.api.ArquillianResource;
      import org.jboss.shrinkwrap.api.Archive;
      import org.jboss.shrinkwrap.api.ShrinkWrap;
      import org.jboss.shrinkwrap.api.spec.WebArchive;
      import org.junit.Assert;
      import org.junit.Test;
      import org.junit.runner.RunWith;
      
      import com.acme.ac.commons.HTTPUtils;
      import com.acme.ac.models.dto.auth.UserDTO;
      
      @RunWith(Arquillian.class)
      @RunAsClient
      public class UserControllerAPITest {
           
              @Deployment(testable = true, managed=true, name="simple")
              @OverProtocol("Servlet 2.5")
              public static Archive<?> createTestArchive() {
                  return ShrinkWrap.create(WebArchive.class, "acme.war")
                          .addAsWebInfResource("applicationContext-arquillian-test.xml", "applicationContext.xml" )
                          .addAsWebInfResource("database-arquillian-test.xml", "databaseTest.xml")
                          .addAsWebInfResource("database-arquillian-test.xml", "database.xml")
                          .addAsWebInfResource("admin-servlet-arquillian-test.xml", "admin-servlet.xml")
                          .addAsWebInfResource("auth-servlet-arquillian-test.xml", "auth-servlet.xml")
                          .addAsWebInfResource("authMethod-all-arquillian-test.xml", "authMethod-all.xml")
                          .addAsWebInfResource("authMethod-oauth-arquillian-test.xml", "authMethod-oauth.xml")
                          .addAsWebInfResource("authMethod-session-arquillian-test.xml", "authMethod-session.xml")
                          .addAsWebInfResource("externalpublishing-servlet-arquillian-test.xml", "externalpublishing-servlet.xml")
                          .addAsWebInfResource("oauth-servlet-arquillian-test.xml", "oauth-servlet.xml")
                          .addAsWebInfResource("form-servlet-arquillian-test.xml", "form-servlet.xml")
                          .addAsWebInfResource("acm-servlet-arquillian-test.xml", "acm-servlet.xml")
                          .addAsWebInfResource("acms-servlet-arquillian-test.xml", "acms-servlet.xml")
                          .addAsWebInfResource("stt-servlet-arquillian-test.xml", "stt-servlet.xml")
                          .addAsWebInfResource("collector-servlet-arquillian-test.xml", "collector-servlet.xml")
                          .addAsWebInfResource("rest-servlet-arquillian-test.xml", "rest-servlet.xml")
                          .addAsWebInfResource("urlrewrite-arquillian-test.xml", "urlrewrite.xml")
                          .addAsResource("logback-arquillian-test.xml", "logback.xml")
                          .addAsManifestResource("arquillian.xml")
                          .setWebXML("in-container-web.xml");
              }
      
      
          @ArquillianResource
          private URL contextPath;
      
           @Test
          public void testGetUserInactive() {
                   UserDTO userDTO = null;
                   String responseBody = null;
                
                   try{
                       responseBody =  HTTPUtils.getResponseBodyAsString(contextPath + "users/activate/2ba46cea0e4720ca122947018311b8f3");
                       userDTO =     new ObjectMapper().readValue(responseBody, UserDTO.class);
                   }catch(Throwable t){
                       Assert.fail("Error while conversion of json object:  " + responseBody);
                   }
                
                   assertNotNull("The returned result from REST service was null.", userDTO);
                   assertNotNull("ID is null", userDTO.getUserId());
          }
      }
      
      
      

       

      If I running tests by Junit Eclipse Plugin it works!

      JUnit-Testes:

      junit-eclipse-plugin-running-arquillian-tests-ok.jpg

       

      my problem is while building the project. The Maven don't understend my arquillian test and I receive the follow error:

      -------------------------------------------------------
      T E S T S
      -------------------------------------------------------
      Running com.acme.ac.api.UserControllerAPITest
      Abr 23, 2015 2:04:20 PM org.apache.coyote.AbstractProtocol init
      INFORMAÇÕES: Initializing ProtocolHandler ["http-bio-8080"]
      Abr 23, 2015 2:04:20 PM org.apache.catalina.core.StandardService startInternal
      INFORMAÇÕES: Starting service arquillian-tomcat-embedded-7
      Abr 23, 2015 2:04:20 PM org.apache.catalina.core.StandardEngine startInternal
      INFORMAÇÕES: Starting Servlet Engine: Apache Tomcat/7.0.29
      Abr 23, 2015 2:04:20 PM org.apache.coyote.AbstractProtocol start
      INFORMAÇÕES: Starting ProtocolHandler ["http-bio-8080"]
      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.207 sec <<< FAILURE!
      Tests in error:
      com.acme.ac.api.UserControllerAPITest: org.apache.catalina.util.ContextName.<init>(Ljava/lang/String;Z)V
      
      
      

       

      what's this error org.apache.catalina.util.ContextName.<init>(Ljava/lang/String;Z)V ? how I solve this?