1 Reply Latest reply on Oct 13, 2014 8:54 AM by Bartosz Majsak

    Testing Servlet application using Arquillian and Tomcat : Error while running junit NoSuchMethodError:ContextName

    Prabha nagaraja Newbie

      Finally I was successful in writing very simple basic unit test . In my next attempt , I am trying to write a unit test for servlets to understand actual use of Arquaillian that is in-container testing. I was partially successful in my attempt. I am getting an error while running an example for Servlet which I had no clue for the root cause.

       

      Please find the exception which is thrown while running a Unit test. Can you please help in resolving and understanding why this is thrown . Is there any other simpler examples which i can try out

       

       

       

      Testsuite: com.acme.servlet.AnnotatedEchoServletTestCase

      Tests run: 0, Failures: 0, Errors: 1, Time elapsed: 0.692 sec

      ------------- Standard Error -----------------

      Aug 31, 2014 6:37:47 PM org.apache.coyote.AbstractProtocol init

      INFO: Initializing ProtocolHandler ["http-bio-8888"]

      Aug 31, 2014 6:37:48 PM org.apache.catalina.core.StandardService startInternal

      INFO: Starting service arquillian-tomcat-embedded-8

      Aug 31, 2014 6:37:48 PM org.apache.catalina.core.StandardEngine startInternal

      INFO: Starting Servlet Engine: Apache Tomcat/7.0.11

      Aug 31, 2014 6:37:48 PM org.apache.coyote.AbstractProtocol start

      INFO: Starting ProtocolHandler ["http-bio-8888"]

      ------------- ---------------- ---------------

       

       

      Testcase: com.acme.servlet.AnnotatedEchoServletTestCase took 0 sec

        Caused an ERROR

      org.apache.catalina.util.ContextName.<init>(Ljava/lang/String;Z)V

      java.lang.NoSuchMethodError: org.apache.catalina.util.ContextName.<init>(Ljava/lang/String;Z)V

        at org.jboss.arquillian.container.tomcat.embedded_8.TomcatContainer.getContextName(TomcatContainer.java:321)

        at org.jboss.arquillian.container.tomcat.embedded_8.TomcatContainer.deleteWar(TomcatContainer.java:333)

        at org.jboss.arquillian.container.tomcat.embedded_8.TomcatContainer.deploy(TomcatContainer.java:205)

        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 org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

        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 org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

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

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

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

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

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

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

        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 org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

        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 org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

        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 org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

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

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

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

        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.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)

        at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)

        at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:424)

        at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:138)

       

      and

       

      Testsuite: com.acme.servlet.RegisteredEchoServletTestCase

      Tests run: 0, Failures: 0, Errors: 1, Time elapsed: 0.057 sec

       

       

      Testcase: com.acme.servlet.RegisteredEchoServletTestCase took 0 sec

        Caused an ERROR

      Could not invoke deployment method: public static org.jboss.shrinkwrap.api.spec.WebArchive com.acme.servlet.RegisteredEchoServletTestCase.getTestArchive()

      java.lang.RuntimeException: Could not invoke deployment method: public static org.jboss.shrinkwrap.api.spec.WebArchive com.acme.servlet.RegisteredEchoServletTestCase.getTestArchive()

        at org.jboss.arquillian.container.test.impl.client.deployment.AnnotationDeploymentScenarioGenerator.invoke(AnnotationDeploymentScenarioGenerator.java:160)

        at org.jboss.arquillian.container.test.impl.client.deployment.AnnotationDeploymentScenarioGenerator.generateDeployment(AnnotationDeploymentScenarioGenerator.java:94)

        at org.jboss.arquillian.container.test.impl.client.deployment.AnnotationDeploymentScenarioGenerator.generate(AnnotationDeploymentScenarioGenerator.java:57)

        at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.generateDeployment(DeploymentGenerator.java:79)

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

        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:100)

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

        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 org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

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

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

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

        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.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)

        at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)

        at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:424)

        at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:138)

      Caused by: java.lang.reflect.InvocationTargetException

        at org.jboss.arquillian.container.test.impl.client.deployment.AnnotationDeploymentScenarioGenerator.invoke(AnnotationDeploymentScenarioGenerator.java:156)

      Caused by: java.lang.IllegalArgumentException: No resource META-INF/services/org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor was found configured for user view class org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor

        at org.jboss.shrinkwrap.descriptor.api.DescriptorInstantiator.getDescriptorConstructionInfoForUserView(DescriptorInstantiator.java:219)

        at org.jboss.shrinkwrap.descriptor.api.DescriptorInstantiator.createFromUserView(DescriptorInstantiator.java:88)

        at org.jboss.shrinkwrap.descriptor.api.Descriptors.create(Descriptors.java:69)

        at org.jboss.shrinkwrap.descriptor.api.Descriptors.create(Descriptors.java:46)

        at com.acme.servlet.RegisteredEchoServletTestCase.getTestArchive(RegisteredEchoServletTestCase.java:37)

       

      Thanks