I'm trying to auto-deploy my webapps to tomcat using Maven plugin tomcat7-maven-plugin. I took the following three steps:

  1. Added a new user with deployment rights to tomcat,
  2. Introduced the mentioned tomcat user to maven,
  3. Edited my project's pom.xml to use the plugin.

For the first step, I added the following lines to the file conf\tomcat-users.xml in tomcat's installation directory:

<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<user username="war-deployer" password="some-password"
    roles="manager-gui,manager-script,manager-jmx" />

and then I restarted tomcat.

For the second step, I added the following to the <servers> node of conf\settings.xml file in MAVEN_HOME directory:


And finally, to take to third step, I added the following lines to <plugins> node of pom.xml in my project to use tomcat7-maven-plugin:


I thought everything would go fine, but when typing the command mvn tomcat7:deploy my webapp didn't get deployed, nothing was added to tomcat's webapps directory, and the following response was sent back from tomcat to the command line:

[INFO] tomcatManager status code:401, ReasonPhrase:
[INFO] <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
[INFO] <html>
[INFO]  <head>
[INFO]   <title>401 Unauthorized</title>
[INFO]   <style type="text/css">
[INFO]     <!--
[INFO]     BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;font-size:12px;}
[INFO]     H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
[INFO]     PRE, TT {border: 1px dotted #525D76}
[INFO]     A {color : black;}A.name {color : black;}
[INFO]     -->
[INFO]   </style>
[INFO]  </head>
[INFO]  <body>
[INFO]    <h1>401 Unauthorized</h1>
[INFO]    <p>
[INFO]     You are not authorized to view this page. If you have not changed
[INFO]     any configuration files, please examine the file
[INFO]     <tt>conf/tomcat-users.xml</tt> in your installation. That
[INFO]     file must contain the credentials to let you use this webapp.
[INFO]    </p>
[INFO]    <p>
[INFO]     For example, to add the <tt>manager-gui</tt> role to a user named
[INFO]     <tt>tomcat</tt> with a password of <tt>s3cret</tt>, add the following to the
[INFO]     config file listed above.
[INFO]    </p>
[INFO] <pre>
[INFO] &lt;role rolename="manager-gui"/&gt;
[INFO] &lt;user username="tomcat" password="s3cret" roles="manager-gui"/&gt;
[INFO] </pre>
[INFO]    <p>
[INFO]     Note that for Tomcat 7 onwards, the roles required to use the manager
[INFO]     application were changed from the single <tt>manager</tt> role to the
[INFO]     following four roles. You will need to assign the role(s) required for
[INFO]     the functionality you wish to access.
[INFO]    </p>
[INFO]     <ul>
[INFO]       <li><tt>manager-gui</tt> - allows access to the HTML GUI and the status
[INFO]           pages</li>
[INFO]       <li><tt>manager-script</tt> - allows access to the text interface and the
[INFO]           status pages</li>
[INFO]       <li><tt>manager-jmx</tt> - allows access to the JMX proxy and the status
[INFO]           pages</li>
[INFO]       <li><tt>manager-status</tt> - allows access to the status pages only</li>
[INFO]     </ul>
[INFO]    <p>
[INFO]     The HTML interface is protected against CSRF but the text and JMX interfaces
[INFO]     are not. To maintain the CSRF protection:
[INFO]    </p>
[INFO]    <ul>
[INFO]     <li>Users with the <tt>manager-gui</tt> role should not be granted either
[INFO]         the <tt>manager-script</tt> or <tt>manager-jmx</tt> roles.</li>
[INFO]     <li>If the text or jmx interfaces are accessed through a browser (e.g. for
[INFO]         testing since these interfaces are intended for tools not humans) then
[INFO]         the browser must be closed afterwards to terminate the session.</li>
[INFO]    </ul>
[INFO]    <p>
[INFO]     For more information - please see the
[INFO]     <a href="/docs/manager-howto.html" rel="noopener noreferrer">Manager App How-To</a>.
[INFO]    </p>
[INFO]  </body>
[INFO] </html>

Although no error was reported by maven, and I received a BUILD SUCCESS at the end. I've been struggling with the problem for several hours, and searched the Web, but I couldn't find the solution to it. What's wrong with the process that I've followed? Please help me solve it. Thank you very much.

  • 1
    Did you get a 401 with the default tomcat installation?
    – 030
    Commented Dec 31, 2019 at 22:02
  • @030 I don't know what you mean by default tomcat installation. But except for the settings related to adding the new user war-deployer and its roles, I've changed none of the tomcat's default settings. Commented Jan 1, 2020 at 0:34

1 Answer 1


That's because you forgot to link the <configuration> for the plugin with the <server> definition in settings.xml., and the tomcat7 plugin is trying to deploy as un-authenticated because it has not credentials to try.

Add <server>maven-tomcat-war-deployment-server</server> in the configuration section of the plugin:

  • Thank you @GUDO. This solved the problem. Commented Jan 15, 2020 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.