java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String when deploying to Tomcat in cargo
<p>I am having issues deploying a web application on an embeded Tomcat 7 with the maven-cargo-plugin. I created a new maven profile in the webapps pom that creates a Tomcat container via the maven-cargo-plugin and then executes a soapui test case via the soapui-maven-plugin. </p>

<p>The webapp connects to some IBM WebSphere MQs therefore I have overwritten some of the containers config files:</p>

<ul>
<li>added the MQs as Resources to server.xml for JNDI lookup</li>
<li>added my custom applicationContext.xml to the classpath by overriding the web.xml</li>
<li>added the needed Resources in the context.xml that are needed to connect to the MQs</li>
<li>added the path to the lib directory of a locally installed IBM Websphere MQClient to the containers common.loader so that its libs can be used by the container </li>
</ul>

<p>Furthermore I copied the needed websphere.mq.*.jar files and j2ee-1.4.jar from a local WebsSphere Server installation to the Tomcat containers lib directory by adding them via cargos <code>&lt;file&gt;</code> tag.</p>

<p>Now when I startup Maven with this command (where runITs activates the created profile):</p>

<pre><code>clean verify -U -Dhttps.protocols=TLSv1,SSLv3 -DrunITs -X
</code></pre>

<p>The deploy fails with:</p>

<pre><code>INFO] [talledLocalContainer] org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/cargocpc]]
[INFO] [talledLocalContainer]   at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
[INFO] [talledLocalContainer]   at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1081)
[INFO] [talledLocalContainer]   at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1877)
[INFO] [talledLocalContainer]   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
[INFO] [talledLocalContainer]   at java.util.concurrent.FutureTask.run(FutureTask.java:262)
[INFO] [talledLocalContainer]   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[INFO] [talledLocalContainer]   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
[INFO] [talledLocalContainer]   at java.lang.Thread.run(Thread.java:745)
[INFO] [talledLocalContainer] Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getClassLoader()Ljava/lang/ClassLoader;
[INFO] [talledLocalContainer]   at org.apache.catalina.startup.WebappServiceLoader.load(WebappServiceLoader.java:90)
[INFO] [talledLocalContainer]   at org.apache.catalina.startup.ContextConfig.processServletContainerInitializers(ContextConfig.java:1577)
[INFO] [talledLocalContainer]   at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1281)
[INFO] [talledLocalContainer]   at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:889)
[INFO] [talledLocalContainer]   at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:386)
[INFO] [talledLocalContainer]   at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
[INFO] [talledLocalContainer]   at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5412)
[INFO] [talledLocalContainer]   at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
[INFO] [talledLocalContainer]   ... 10 more
</code></pre>

<p>I already tried to search for possible solutions and f. e. tried the solution provided here: <a href="https://stackoverflow.com/questions/8611777/java-lang-nosuchmethoderror-javax-servlet-servletcontext-getcontextpathljava">java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String;</a></p>

<p>but I could rule out the possible causes because:</p>

<ul>
<li>my container is Tomcat 7 and therefore supports Servlet API 2.5</li>
<li>the web.xml complies Servlet API 2.5</li>
<li>There are no j2ee.jar or servlet-api.jar files in <code>WEB-INF/lib</code> or <code>JRE/lib</code></li>
</ul>

<p>After making sure my setup complies these three points I still get the error mentioned above.</p>

<p>Does anyone know what else could cause this?</p>