401 Unauthorized error while logging in Manager-App of Tomcat

后端 未结 19 2339
谎友^
谎友^ 2020-12-14 07:37

I am trying to log in to the Manager App in Tomcat 7.0.22 for Mac OS X 10.7. Here is the error I am getting: http://f.cl.ly/items/421q1K3f1i0X1H1M181v/so.tiff



        
相关标签:
19条回答
  • 2020-12-14 08:00

    Its unlikely that anybody made the same mistake I did, but incase you have a couple versions of tomcat (or have fudged the installation and have files you need to cleanup) make sure you are in the correct folder.

    I was looking at the config file in C:\tomcat7\ but the actual Tomcat that was running was in C:\Program Files\Apache Software Foundation\Tomcat 7.0\

    0 讨论(0)
  • 2020-12-14 08:00

    Shutdown tomcat

    paste below comments complete content into tomcat-users.xml and save

    start tomcat

    Now Build it should work, i did for windows OS with Jenkins and git deployment via tomcat7

    <?xml version="1.0" encoding="UTF-8"?>
    -<tomcat-users> <role rolename="manager-gui"/> <role rolename="manager-script"/> <role rolename="manager-jmx"/> <role rolename="manager-status"/> <role rolename="admin-gui"/> <role rolename="admin-script"/> <user roles="manager-gui, manager-script, manager-jmx, manager-status, admin-gui, admin-script" password="admin" username="admin"/> </tomcat-users>
    
    0 讨论(0)
  • 2020-12-14 08:02

    Just to add some information on @David's answer:

    If you are like me and SFTP to the host with any user under a group other than tomcat (for e.g. root) and edit tomcat_users.xml with some generic editor like gedit or VS Code, the group of the file will be changed to the user you used (probably because a new file was created). Like below:

    drwxr-x--- 2 root tomcat   4096 Jun 21 11:41 ./
    drwxr-xr-x 9 root tomcat   4096 May 24 14:12 ../
    -rw-r----- 1 root tomcat  13531 Apr 28 03:34 catalina.policy
    -rw-r----- 1 root tomcat   7202 Apr 28 03:34 catalina.properties
    -rw-r----- 1 root tomcat   1400 Apr 28 03:34 context.xml
    -rw-r----- 1 root tomcat   1149 Apr 28 03:34 jaspic-providers.xml
    -rw-r----- 1 root tomcat   2313 Apr 28 03:34 jaspic-providers.xsd
    -rw-r----- 1 root tomcat   3850 Apr 28 03:34 logging.properties
    -rw-r----- 1 root tomcat   7511 Apr 28 03:34 server.xml
    -rw-r----- 1 root root     2342 Jun 21 11:41 tomcat-users.xml
    -rw-r----- 1 root tomcat   2633 Apr 28 03:34 tomcat-users.xsd
    -rw-r----- 1 root tomcat 170202 Apr 28 03:34 web.xml
    

    Maybe my initial setup of tomcat was a bit casual... But with the above behavior, tomcat will loose access to the edited file. The result would be 401 Unauthorized.

    There are a number of options to get around the problem. I'm not sure if any of them is the best practice though.

    • Changing permission after the edit (yes sure...).
    • nano and WinSCP do not seem to suffer from the issue.
    • SETGID: chmod g+s /conf_folder (not tested).
    • Follow this answer
    • Maybe an editor that is permission-aware?
    0 讨论(0)
  • 2020-12-14 08:03

    I was using a particular complex password with lots of odd characters. Just return that back to regular password and worked fine.

    0 讨论(0)
  • 2020-12-14 08:04

    Changing the port from 8080 to 8088 in server.xml worked for me.Refer the code below

    <Connector port="8088" protocol="HTTP/1.1" 
    connectionTimeout="20000"
    redirectPort="8443" />
    
    0 讨论(0)
  • 2020-12-14 08:05

    Sorry, I have to ask the obvious: Did you restart Tomcat?

    If that doesn't work, try adding "admin-gui" to your roles:

    <user name="tomcat" password="s3cret" roles="admin-gui,standard,manager-gui"/>
    
    0 讨论(0)
提交回复
热议问题