Tomcat 7 Manager can't login

后端 未结 8 1765
生来不讨喜
生来不讨喜 2020-12-29 07:34

Trying to log in but can\'t. My tomcat-users.xml, modified as I saw it here.

    
   
            


        
相关标签:
8条回答
  • 2020-12-29 08:11

    I had some problems with access Tomcat's manager (v8.0) as part of NetBeans (v8.2) IDE under Windows 10.

    The actual tomcat-users.xml file to add gui-manager user/password pairs is located at C:\Users\\AppData\Roaming\NetBeans\8.2\apache-tomcat-8.0.27.0_base\conf\ path. Open tomcat-users.xml file and add some rows:

      <role rolename="manager-gui"/>
      <role rolename="manager-script"/>
      <role rolename="manager-jmx"/>
      <role rolename="manager-status"/>
      <user username="root" password="root" roles="manager-gui,manager-script,manager-jmx,manager-status"/>
    

    After that you should restart Tomcat and try access manager again.

    0 讨论(0)
  • 2020-12-29 08:15

    And also check if it is not commented with:

    <!-- ... -->
    
    0 讨论(0)
  • 2020-12-29 08:22

    Remove the spaces between the roles for admin/admin. The list should just be comma separated as so:

    <?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 username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/>
    </tomcat-users>
    
    0 讨论(0)
  • 2020-12-29 08:23

    I had the same issue but for me the reason was the server.xml file.

    Within the file there is a tag which specifies the path of the tomcat-users.xml:

      <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <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="/etc/tomcat7/tomcat-users.xml" />
    

    You have to make sure the pathname is set correctly to the location of your tomcat-users.xml file.

    0 讨论(0)
  • 2020-12-29 08:24

    You also need to restart Tomcat after making changes to tomcat-users.xml or server.xml, context.xml or web.xml for the changes to be effective.

    In my case, the problem was I did not restart Tomcat after making changes. Also on Tomcat 7 I had assigned manager-script, manager-gui roles to the same user. So Tomcat gave 403 error to enforce CRSF protection.

    Wrong:

    <role rolename="manager-script" />
    <role rolename="manager-gui" />
    <user username="maven-deployer" password="s3cret" roles="manager-script,manager-gui" />
    

    Correct:

    <role rolename="manager-script" />
    <role rolename="manager-gui" />
    <user username="maven-deployer" password="s3cret" roles="manager-script" />
    <user username="gui-manager" password="s3cret" roles="manager-gui" />
    
    0 讨论(0)
  • 2020-12-29 08:27

    Check the permissions and ownership on the file '/etc/tomcat7/tomcat-users.xml'. It should owned by root and group ownership should be tomcat7.

    -rw-r----- 1 root tomcat7 2101 Jan 22 10:34 tomcat-users.xml

    This is on Ubuntu 14.04.3 LTS, YMMV

    0 讨论(0)
提交回复
热议问题