title: Unable to sign in to Tomcat Manager with correct username password and roles
body: <p>I am trying to sign in to Tomcat <code>manager</code> and <code>host-manager</code> webapps which I have hosted on Amazon Web Service.</p>
  
  <p><strong>Even after entering the correct password in the popup, the pop up keeps showing and if I cancel it, then I am redirected to 401 error page</strong></p>
  
  <p>I have updated <code>/etc/tomcat8/tomcat-users.xml</code> correctly.</p>
  
  <p>It stopped working after I added <code>&lt;Context path="" docBase="mywebapp" debug="0" privileged="true" /&gt;</code> inside server.xml</p>
  
  <p><strong>/etc/tomcat8/tomcat-users.xml</strong></p>
  
  <pre><code>&lt;role rolename="manager-gui"/&gt;
  &lt;user username="supermanager" password="superpassword" roles="manager-gui" /&gt;
  
  &lt;role rolename="admin-gui"/&gt;
  &lt;user username="superadmin" password="superpassword" roles="admin-gui"/&gt;
  &lt;/tomcat-users&gt;
  </code></pre>
  
  <p><strong>server.xml</strong></p>
  
  <pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
  
  &lt;Server port="8005" shutdown="SHUTDOWN"&gt;
    &lt;Listener className="org.apache.catalina.startup.VersionLoggerListener" /&gt;
  
    &lt;Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /&gt;
    &lt;Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /&gt;
    &lt;Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /&gt;
  
  
    &lt;GlobalNamingResources&gt;
  
      &lt;Resource name="UserDatabase" auth="Container"
                type="org.apache.catalina.UserDatabase"
                description="User database that can be updated and saved"
                factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
                pathname="conf/tomcat-users.xml" /&gt;
    &lt;/GlobalNamingResources&gt;
  
    &lt;Service name="Catalina"&gt;
  
      &lt;Connector port="8080" proxyPort="80" protocol="HTTP/1.1"
                 connectionTimeout="20000"
                 URIEncoding="UTF-8"
                 redirectPort="8443" /&gt;
  
      &lt;Engine name="Catalina" defaultHost="MYDOMAIN.COM"&gt;
  
        &lt;Realm className="org.apache.catalina.realm.LockOutRealm"&gt;
          &lt;Realm className="org.apache.catalina.realm.UserDatabaseRealm"
                 resourceName="UserDatabase"/&gt;
        &lt;/Realm&gt;
  
        &lt;Host name="MYDOMAIN.COM"  appBase="webapps"
              unpackWARs="true" autoDeploy="true"&gt;
      &lt;Context path="" docBase="mywebapp" debug="0" privileged="true" /&gt; 
  
          &lt;Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
                 prefix="localhost_access_log" suffix=".txt"
                 pattern="%h %l %u %t &amp;quot;%r&amp;quot; %s %b" /&gt;
  
        &lt;/Host&gt;
      &lt;/Engine&gt;
    &lt;/Service&gt;
  &lt;/Server&gt;
  </code></pre>
  
  <p><strong>/etc/tomcat8/Catalina/localhost/manager.xml(host-manager.xml)</strong></p>
  
  <p><strong>/etc/tomcat8/Catalina/MYDOMAIN.COM/manager.xml(host-manager.xml)</strong></p>
  
  <pre><code>&lt;Context path="/manager" 
          docBase="/usr/share/tomcat8-admin/manager"
          antiResourceLocking="false" privileged="true" /&gt;
  </code></pre>