title: Cannot invoke Tomcat manager: Server returned HTTP response code: 401
body: <p>I am trying to deploy a war to a remote tomcat server from maven, but I get the following error in NetBeans:</p>
  
  <pre><code>Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli)
  on project noca: Cannot invoke Tomcat manager:
  Server returned HTTP response code: 401 for URL:
  http://12.34.56.78/manager/html/deploy?path=%2Fnoca&amp;war= -&gt; [Help 1]
  </code></pre>
  
  <p>I find it strange that there is no value for <code>war</code> and I don't know why.</p>
  
  <p>When I browse this URL, I get the following in Tomcat's manager:</p>
  
  <pre><code>FAIL - Invalid context path null was specified
  </code></pre>
  
  <p>Here is my <code>pom.xml</code>:</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;net.test&lt;/groupId&gt;
      &lt;artifactId&gt;noca&lt;/artifactId&gt;
      &lt;version&gt;1.0.0&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
  
      &lt;properties&gt;
          &lt;endorsed.dir&gt;${project.build.directory}/endorsed&lt;/endorsed.dir&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax&lt;/groupId&gt;
              &lt;artifactId&gt;javaee-web-api&lt;/artifactId&gt;
              &lt;version&gt;6.0&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;4.8.2&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.3.2&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.6&lt;/source&gt;
                      &lt;target&gt;1.6&lt;/target&gt;
                      &lt;compilerArguments&gt;
                          &lt;endorseddirs&gt;${endorsed.dir}&lt;/endorseddirs&gt;
                      &lt;/compilerArguments&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&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.1.1&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.1&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;phase&gt;validate&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;copy&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;outputDirectory&gt;${endorsed.dir}&lt;/outputDirectory&gt;
                              &lt;silent&gt;true&lt;/silent&gt;
                              &lt;artifactItems&gt;
                                  &lt;artifactItem&gt;
                                      &lt;groupId&gt;javax&lt;/groupId&gt;
                                      &lt;artifactId&gt;javaee-endorsed-api&lt;/artifactId&gt;
                                      &lt;version&gt;6.0&lt;/version&gt;
                                      &lt;type&gt;jar&lt;/type&gt;
                                  &lt;/artifactItem&gt;
                              &lt;/artifactItems&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
  
              &lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                  &lt;artifactId&gt;tomcat-maven-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;server&gt;Plasma01&lt;/server&gt;
                      &lt;url&gt;http://12.34.56.78/manager/html&lt;/url&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
  
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>The server is properly defined in my maven <code>setting.xml</code>.</p>
  
  <p>What am I doing wrong?</p>
  
  <p><strong>P.S.</strong>: I have seen this similar <a href="https://stackoverflow.com/questions/7338248/tomcat-maven-plugin-401-error">question</a>, but it does not answer the issue I have.</p>
  
  <p><strong>SOLUTION</strong></p>
  
  <p>For the record, I modified my <code>pom.xml</code> as following following Alexey's suggestion and it works:</p>
  
  <pre><code>    &lt;!-- plugin&gt;
          &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
          &lt;artifactId&gt;tomcat-maven-plugin&lt;/artifactId&gt;
          &lt;configuration&gt;
              &lt;server&gt;Plasma01&lt;/server&gt;
              &lt;url&gt;http://12.34.56.78/manager/html&lt;/url&gt;
          &lt;/configuration&gt;
      &lt;/plugin --&gt;
  
      &lt;plugin&gt;
          &lt;groupId&gt;org.codehaus.cargo&lt;/groupId&gt;
          &lt;artifactId&gt;cargo-maven2-plugin&lt;/artifactId&gt;
          &lt;configuration&gt;
              &lt;container&gt;
                  &lt;containerId&gt;tomcat6x&lt;/containerId&gt;
                  &lt;type&gt;remote&lt;/type&gt;
              &lt;/container&gt;
          &lt;configuration&gt;
          &lt;type&gt;runtime&lt;/type&gt;
          &lt;properties&gt;
              &lt;cargo.tomcat.manager.url&gt;
                  http://12.34.56.78/manager
              &lt;/cargo.tomcat.manager.url&gt;
              &lt;cargo.remote.username&gt;xxxx&lt;/cargo.remote.username&gt;
              &lt;cargo.remote.password&gt;yyyy&lt;/cargo.remote.password&gt;
          &lt;/properties&gt;
          &lt;/configuration&gt;
              &lt;deployer&gt;
                  &lt;type&gt;remote&lt;/type&gt;
                  &lt;deployables&gt;
                      &lt;deployable&gt;
                          &lt;groupId&gt;net.test&lt;/groupId&gt;
                          &lt;artifactId&gt;noca&lt;/artifactId&gt;
                          &lt;type&gt;war&lt;/type&gt;
                      &lt;/deployable&gt;
                  &lt;/deployables&gt;
              &lt;/deployer&gt;
          &lt;/configuration&gt;
      &lt;/plugin&gt;
  </code></pre>