title: Tomcat - Maven plugin: run webapps but not current project
body: <p>The <code>tomcat7-maven-plugin</code> allows running the current project as a Web application and additional <code>&lt;webapps&gt;</code> can be specified that will be simultaneously loaded into tomcat.</p>
  
  <p>My project is not a Web application, but it accesses services that are provided by webapps. So how is it possible to deploy a number of webapps without running the project itself as a webapp? The following Maven snippet results in FileNotFoundExceptions because a context.xml cannot be found. </p>
  
  <pre><code>&lt;plugin&gt;
    &lt;groupId&gt;org.apache.tomcat.maven&lt;/groupId&gt;
    &lt;artifactId&gt;tomcat7-maven-plugin&lt;/artifactId&gt;
    &lt;version&gt;2.0&lt;/version&gt;
    &lt;executions&gt;
      &lt;execution&gt;
        &lt;id&gt;run-tomcat&lt;/id&gt;
        &lt;phase&gt;${tomcat.run.phase}&lt;/phase&gt;
        &lt;goals&gt;&lt;goal&gt;run-war-only&lt;/goal&gt;&lt;/goals&gt;
        &lt;configuration&gt;
          &lt;webapps&gt;
            &lt;webapp&gt;
              &lt;contextPath&gt;/my/app1&lt;/contextPath&gt;
              &lt;groupId&gt;...&lt;/groupId&gt; 
              &lt;artifactId&gt;...&lt;/artifactId&gt;
              &lt;version&gt;...&lt;/version&gt;
              &lt;type&gt;war&lt;/type&gt;    
              &lt;asWebapp&gt;true&lt;/asWebapp&gt;
            &lt;/webapp&gt;
            ... possibly more webapps ...
          &lt;/webapps&gt; 
        &lt;/configuration&gt;
      &lt;/execution&gt;
      &lt;execution&gt;
        &lt;id&gt;tomcat-shutdown&lt;/id&gt;
        &lt;phase&gt;${tomcat.shutdown.phase}&lt;/phase&gt;
        &lt;goals&gt;&lt;goal&gt;shutdown&lt;/goal&gt;&lt;/goals&gt;
      &lt;/execution&gt;
    &lt;/executions&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p><strong>Workaround:</strong></p>
  
  <p>Even though your application itself is not a webapp, you need to configure a <code>path</code> and a <code>contextFile</code> for it:</p>
  
  <pre><code>&lt;configuration&gt;
      &lt;path&gt;/my/non/existing/webapp&lt;/path&gt;
      &lt;contextFile&gt;src/test/resources/context.xml&lt;/contextFile&gt;
      &lt;webapps&gt;
      ...
  </code></pre>
  
  <p>The specified <code>context.xml</code> file must exist. The following worked for me, even though the <code>web.xml</code> file does not exist:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Context path="/my/non/existing/webapp"&gt;
      &lt;WatchedResource&gt;WEB-INF/web.xml&lt;/WatchedResource&gt;
  &lt;/Context&gt;
  </code></pre>