title: tomcat7-maven-plugin contextFile on remote server
body: <p>I am trying to setup maven to deploy my application to Tomcat for different environments. Everything works when I deploy to localhost, but when trying to deploy to a development server, it fails to deploy. However if I tell the tomcat7-maven-plugin not to deploy the context.xml file, everything works.</p>
  
  <p><strong>pom.xml</strong></p>
  
  <pre><code>...
  &lt;profiles&gt;
      &lt;profile&gt;
          &lt;id&gt;local&lt;/id&gt;
          &lt;build&gt;
              &lt;plugins&gt;
                  &lt;plugin&gt;
                      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                      &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
                      &lt;version&gt;2.4&lt;/version&gt;
                      &lt;configuration&gt;
                          &lt;webXml&gt;src\main\webapp\WEB-INF\web.xml&lt;/webXml&gt;
                      &lt;/configuration&gt;
                  &lt;/plugin&gt;
                  &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.2&lt;/version&gt;
                      &lt;configuration&gt;
                          &lt;url&gt;http://localhost:8888/manager/text&lt;/url&gt;
                          &lt;username&gt;admin&lt;/username&gt;
                          &lt;password&gt;admin&lt;/password&gt;
                          &lt;mode&gt;both&lt;/mode&gt;
                          &lt;contextFile&gt;${project.build.directory}/${project.build.finalName}/META-INF/local/context.xml&lt;/contextFile&gt;
                      &lt;/configuration&gt;
                  &lt;/plugin&gt;
              &lt;/plugins&gt;
          &lt;/build&gt;
      &lt;/profile&gt;
      &lt;profile&gt;
          &lt;id&gt;dve&lt;/id&gt;
          &lt;build&gt;
              &lt;plugins&gt;
                  &lt;plugin&gt;
                      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                      &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
                      &lt;version&gt;2.4&lt;/version&gt;
                      &lt;configuration&gt;
                          &lt;webXml&gt;src\main\webapp\WEB-INF\web.xml&lt;/webXml&gt;
                      &lt;/configuration&gt;
                  &lt;/plugin&gt;
                  &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.2&lt;/version&gt;
                      &lt;configuration&gt;
                          &lt;url&gt;http://devserver.mycompany.com:8083/manager/text&lt;/url&gt;
                          &lt;username&gt;myusername&lt;/username&gt;
                          &lt;password&gt;mypassword&lt;/password&gt;
                          &lt;mode&gt;both&lt;/mode&gt;
                          &lt;warFile&gt;${project.build.directory}/${project.build.finalName}.war&lt;/warFile&gt;
                          &lt;contextFile&gt;${project.build.directory}/${project.build.finalName}/META-INF/dve/context.xml&lt;/contextFile&gt;
                      &lt;/configuration&gt;
                  &lt;/plugin&gt;
              &lt;/plugins&gt;
          &lt;/build&gt;
      &lt;/profile&gt;
  &lt;/profiles&gt;
  ...
  </code></pre>
  
  <p>This is what maven tells me when running <em>mvn tomcat7:redeploy -Pdve</em>:</p>
  
  <pre><code>...
  [INFO] Deploying war and context to http://devserver.mycompany:8083/myProject
  [DEBUG] No server specified for authentication - using defaults
  [INFO] OK - Undeployed application at context path /eDiscovery
  [INFO] FAIL - Failed to deploy application at context path /eDiscovery
  ...
  </code></pre>
  
  <p>And here is the catalina.out from "devserver"</p>
  
  <pre><code>Jan 10, 2014 1:34:00 PM org.apache.catalina.core.ApplicationContext log
  INFO: Manager: install: Installing context configuration at 'file:/C:/Users/MyLocalUserName/git/myProject/target/myProject-0.0.1/META-INF/dve/context.xml' from 'file:/C:/Users/MyLocalUserName/git/myProject/target/myProject-0.0.1.war'
  Jan 10, 2014 1:34:00 PM org.apache.catalina.core.ApplicationContext log
  INFO: Manager: undeploy: Undeploying web application at '/myProject'
  Jan 10, 2014 1:34:01 PM org.apache.catalina.startup.HostConfig checkResources
  INFO: Undeploying context [/myProject]
  java.io.FileNotFoundException: /C:/Users/MyLocalUserName/git/myProject/target/myProject-0.0.1/META-INF/dve/context.xml (No such file or directory)
      at java.io.FileInputStream.open(Native Method)
      at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:120)
      at org.apache.catalina.manager.ManagerServlet.copyInternal(ManagerServlet.java:1652)
      at org.apache.catalina.manager.ManagerServlet.copy(ManagerServlet.java:1613)
      at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:843)
      at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:353)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:662)
  java.io.FileNotFoundException: /C:/Users/MyLocalUserName/git/myProject/target/myProject-0.0.1.war (No such file or directory)
      at java.io.FileInputStream.open(Native Method)
      at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:120)
      at org.apache.catalina.manager.ManagerServlet.copyInternal(ManagerServlet.java:1652)
      at org.apache.catalina.manager.ManagerServlet.copy(ManagerServlet.java:1613)
      at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:848)
      at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:353)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:662)
  </code></pre>
  
  <p>It looks like the server is trying to load the context.xml file from my local path, that it does not have access to. Does anyone know how to fix this? If I turn off the loading of the context.xml (by changing the <strong>mode</strong> from <em>both</em> to <em>war</em> in the pom file.) everything works fine and the application loads.</p>
  
  <p>Thanks.</p>