tomcatnetbeanstomcat10

Access to Tomcat server has not been authorized. Set the correct username and password with the "manager-script"


I am using jdk 17, tomcat 10.1.17 and netbeans IDE 17. When running any project, the "Authentication required" dialog box always appears to ask me to enter username and password. Even though I entered it correctly, it does not work and keeps asking me to re-enter it. When I close the dialog box, the output message is:

Deployment error: Access to Tomcat server has not been authorized. Set the correct username and password with the "manager-script" role in the Tomcat customizer in the Server Manager. See the server log for details.

When I close the dialog box, the output message is:

Properties:

tomcat-users.xml file in cof folder:

after some observation i realized when i start the server it will give this error:

WARNING [http-nio-8080-exec-5] org.apache.catalina.realm.LockOutRealm.filterLockedAccounts An attempt was made to authenticate the locked user [admin]

I have tried methods such as deleting and reinstalling, running Netbeans with administrator rights, editing the tomcat-users.xml file, changing the server port, switching from "Use system proxy settings" to "No proxy" but they all do not work. Hope to receive the fastest help


Solution

  • Your tomcat-users.xml is not correct. You need to declare the roles (and obviously use the correct tag tomcat-users and not brokenDocument):

    <?xml version='1.0' encoding='utf-8'?>
    <tomcat-users>
    <!--
      NOTE:  By default, no user is included in the "manager-gui" role required
      to operate the "/manager/html" web application.  If you wish to use this app,
      you must define such a user - the username and password are arbitrary.
    -->
      <role rolename="admin-gui"/>
      <role rolename="manager-gui"/>
      <user name="sa" password="123" roles="admin-gui,manager-gui"/>
    </tomcat-users>
    

    See also: https://github.com/apache/tomcat/blob/main/conf/tomcat-users.xml

    Besides that: please don't post screenshots of text.