<p>Quickly going through this it looks like you have added wrong credentials to Jenkins. Can you please check the added credentials first. </p>

<pre><code>aused by: org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: The username and password you provided are not correct (error 401)
</code></pre>

CC BY-SA 4.0
2018-11-16T17:17:58.387Z
2018-11-16T17:17:58.387Z
NIK
<p>I have Jenkins installed in my system, on which the following are installed: </p>

<ul>
<li>Maven Integration Plugin</li>
<li>Deploy to Container Plugin</li>
<li>Ant Plugin</li>
<li>Copy Artifact Plugin</li>
<li>GitHub plugin</li>
<li>GitHub Branch Source Plugin</li>
</ul>

<p>.. and possibly a few others I cannot remember (because coding)...</p>

<p>create new freestyle Project (Deploy-to-staging) project, go to its config, and do the following:</p>

<ul>
<li>In Build, select copy artifacts from another project (package):</li>
</ul>

<p><a href="https://i.sstatic.net/34qkH.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/34qkH.png" alt="In Build, select copy artifacts from another project (package):"></a></p>

<ul>
<li><p>In select post build action</p>

<p><a href="https://i.sstatic.net/5cLJe.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/5cLJe.png" alt="In select post build action"></a></p></li>
</ul>

<p>In package project, edited its config as follows:</p>

<ul>
<li>In General, describe the project.</li>
<li>In Source Code Management, select Git and enter the Repository URL.</li>
<li>In Build,Select Invoke top-level Maven Target.</li>
</ul>

<p><a href="https://i.sstatic.net/BA0Mh.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/BA0Mh.png" alt="In Build, Invoke top-level Maven Target."></a></p>

<ul>
<li>In post build actions, Select Archive the Artifacts and Build other project.</li>
</ul>

<p><a href="https://i.sstatic.net/yamqr.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/yamqr.png" alt="In post build actions, Select Archive the Artifacts and Build other project."></a> </p>

<p>When I trigger the package build it runs fine and Deploy-to-staging</p>

<p>Build step failed with exception org.codehaus.cargo.container.ContainerException: Failed to redeploy</p>

<p>I get below error when trying to deploy a WAR using Jenkins.</p>

<pre><code>    Building in workspace /var/lib/jenkins/workspace/Deploy-to-staging
Copied 1 artifact from "Package" build number 31
Deploying /var/lib/jenkins/workspace/Deploy-to-staging/webapp/target/webapp.war to container Tomcat 7.x Remote with context 
ERROR: Build step failed with exception
org.codehaus.cargo.container.ContainerException: Failed to redeploy [/var/lib/jenkins/workspace/Deploy-to-staging/webapp/target/webapp.war]
    at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:188)
    at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:77)
    at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:147)
    at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:117)
    at hudson.FilePath.act(FilePath.java:1077)
    at hudson.FilePath.act(FilePath.java:1060)
    at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:114)
    at hudson.plugins.deploy.PasswordProtectedAdapterCargo.redeploy(PasswordProtectedAdapterCargo.java:93)
    at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:64)
    at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
    at hudson.model.Build$BuildExecution.post2(Build.java:186)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
    at hudson.model.Run.execute(Run.java:1844)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)
Caused by: org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: The username and password you provided are not correct (error 401)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:698)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.list(TomcatManager.java:876)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.getStatus(TomcatManager.java:889)
    at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:173)
    ... 17 more
Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: http://localhost:8090/manager/text/list
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1894)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:571)
    ... 20 more
org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: The username and password you provided are not correct (error 401)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:698)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.list(TomcatManager.java:876)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.getStatus(TomcatManager.java:889)
    at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:173)
    at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:77)
    at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:147)
    at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:117)
    at hudson.FilePath.act(FilePath.java:1077)
    at hudson.FilePath.act(FilePath.java:1060)
    at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:114)
    at hudson.plugins.deploy.PasswordProtectedAdapterCargo.redeploy(PasswordProtectedAdapterCargo.java:93)
    at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:64)
    at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
    at hudson.model.Build$BuildExecution.post2(Build.java:186)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
    at hudson.model.Run.execute(Run.java:1844)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)
Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: http://localhost:8090/manager/text/list
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1894)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:571)
    ... 20 more
Build step 'Deploy war/ear to a container' marked build as failure
Finished: FAILURE
</code></pre>

<p>How can I fix this?</p>

<p>My tomcat credentials, located in [tomcat directory]/conf/tomcat-users.xml, are as follows:</p>

<pre><code>  &lt;role rolename="manager-script"/&gt;
  &lt;role rolename="manager-gui"/&gt;
  &lt;role rolename="manager-jmx"/&gt;
  &lt;role rolename="manager-status"/&gt;
  &lt;role rolename="admin-gui"/&gt;
&lt;user username="tomcat" password="tomcat" roles="manager-script,admin-gui,manager-gui,manager-jmx,manager-status"/&gt;
</code></pre>

CC BY-SA 4.0
2019-09-12T17:56:26.893Z
How did u fix this issue? I am facing the same exact problem. And my credentials to tomcat container look good.
Dhruvajyoth Reddy Kommuri
<jenkins><maven><java><tomcat>
Deploy war/ear to a container' marked build as failure
Sparsh Dixit
# Deploy war/ear to a container' marked build as failure

(Asked by: username_0 on 2018-11-16)

I have Jenkins installed in my system, on which the following are installed: 

Maven Integration Plugin
Deploy to Container Plugin
Ant Plugin
Copy Artifact Plugin
GitHub plugin
GitHub Branch Source Plugin

.. and possibly a few others I cannot remember (because coding)...
create new freestyle Project (Deploy-to-staging) project, go to its config, and do the following:

In Build, select copy artifacts from another project (package):



In select post build action


In package project, edited its config as follows:

In General, describe the project.
In Source Code Management, select Git and enter the Repository URL.
In Build,Select Invoke top-level Maven Target.



In post build actions, Select Archive the Artifacts and Build other project.

 
When I trigger the package build it runs fine and Deploy-to-staging
Build step failed with exception org.codehaus.cargo.container.ContainerException: Failed to redeploy
I get below error when trying to deploy a WAR using Jenkins.
    Building in workspace /var/lib/jenkins/workspace/Deploy-to-staging
Copied 1 artifact from "Package" build number 31
Deploying /var/lib/jenkins/workspace/Deploy-to-staging/webapp/target/webapp.war to container Tomcat 7.x Remote with context 
ERROR: Build step failed with exception
org.codehaus.cargo.container.ContainerException: Failed to redeploy [/var/lib/jenkins/workspace/Deploy-to-staging/webapp/target/webapp.war]
    at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:188)
    at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:77)
    at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:147)
    at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:117)
    at hudson.FilePath.act(FilePath.java:1077)
    at hudson.FilePath.act(FilePath.java:1060)
    at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:114)
    at hudson.plugins.deploy.PasswordProtectedAdapterCargo.redeploy(PasswordProtectedAdapterCargo.java:93)
    at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:64)
    at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
    at hudson.model.Build$BuildExecution.post2(Build.java:186)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
    at hudson.model.Run.execute(Run.java:1844)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)
Caused by: org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: The username and password you provided are not correct (error 401)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:698)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.list(TomcatManager.java:876)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.getStatus(TomcatManager.java:889)
    at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:173)
    ... 17 more
Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: http://localhost:8090/manager/text/list
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1894)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:571)
    ... 20 more
org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: The username and password you provided are not correct (error 401)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:698)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.list(TomcatManager.java:876)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.getStatus(TomcatManager.java:889)
    at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:173)
    at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:77)
    at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:147)
    at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:117)
    at hudson.FilePath.act(FilePath.java:1077)
    at hudson.FilePath.act(FilePath.java:1060)
    at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:114)
    at hudson.plugins.deploy.PasswordProtectedAdapterCargo.redeploy(PasswordProtectedAdapterCargo.java:93)
    at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:64)
    at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
    at hudson.model.Build$BuildExecution.post2(Build.java:186)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
    at hudson.model.Run.execute(Run.java:1844)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)
Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: http://localhost:8090/manager/text/list
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1894)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:571)
    ... 20 more
Build step 'Deploy war/ear to a container' marked build as failure
Finished: FAILURE

How can I fix this?
My tomcat credentials, located in [tomcat directory]/conf/tomcat-users.xml, are as follows:

**Tags:** jenkins, maven, java, tomcat

> **Comments:**
> **username_1**: How did u fix this issue? I am facing the same exact problem. And my credentials to tomcat container look good.  

---

## 1 answers

### Answer by username_2 on 2018-11-16. Score: 1

Quickly going through this it looks like you have added wrong credentials to Jenkins. Can you please check the added credentials first. 
aused by: org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: The username and password you provided are not correct (error 401)


---

