无法查看服务器状态,Tomcat中的pipe理器应用程序页面:不接受用户名和密码,为什么?

我无法查看Tomcat中的服务器状态和pipe理器应用程序页面。

在这里输入图像说明

虽然我在tomcat-users.xmlconfiguration了用户名和密码,但是它不接受这个组合并显示这个消息:

 401 Unauthorized You are not authorized to view this page. If you have not changed any configuration files, please examine the file conf/tomcat-users.xml in your installation. That file must contain the credentials to let you use this webapp. For example, to add the manager-gui role to a user named tomcat with a password of s3cret, add the following to the config file listed above. <role rolename="manager-gui"/> <user username="tomcat" password="s3cret" roles="manager-gui"/> Note that for Tomcat 7 onwards, the roles required to use the manager application were changed from the single manager role to the following four roles. You will need to assign the role(s) required for the functionality you wish to access. manager-gui - allows access to the HTML GUI and the status pages manager-script - allows access to the text interface and the status pages manager-jmx - allows access to the JMX proxy and the status pages manager-status - allows access to the status pages only The HTML interface is protected against CSRF but the text and JMX interfaces are not. To maintain the CSRF protection: Users with the manager-gui role should not be granted either the manager-script or manager-jmx roles. If the text or jmx interfaces are accessed through a browser (eg for testing since these interfaces are intended for tools not humans) then the browser must be closed afterwards to terminate the session. 

我编辑tomcat-users.xml为:

  <tomcat-users> <role rolename="admin"/> <role rolename="admin-gui"/> <role rolename="manager"/> <role rolename="manager-gui"/> <user username="suhail" password="suhail" roles="admin,admin-gui,manager,manager-gui"/> </tomcat-users> 

我把用户名和密码作为suhail 。 为什么不接受组合?

我也挣扎了很多。 这个为我工作。 复制粘贴到tomcat-users.xml下面

 <?xml version='1.0' encoding='utf-8'?> <tomcat-users> <role rolename="tomcat"/> <role rolename="role1"/> <user username="tomcat" password="tomcat" roles="tomcat"/> <user username="both" password="tomcat" roles="tomcat,role1"/> <user username="role1" password="tomcat" roles="role1"/> --> <role rolename="manager-gui" /> <user username="jeril" password="1" roles="manager-gui"/> </tomcat-users> 

在tomcat-users.xml中添加下面的行来检查服务器状态和管理器应用程序。

 <user username="username" password="password" roles="admin-gui,manager-gui"/> 

在你的tomcat-user.xml文件中复制下面的代码并修改用户名和密码

  <?xml version='1.0'?> <tomcat-users> <user name="username" password="password" roles="admin-gui,manager-gui" /> </tomcat-users> 

重启tomcat

我从我的IDE (Netbeans)启动服务器Tomcat 。 所以,我必须从Netbeans设置中更改配置:

在这里输入图像说明

现在它按预期工作!

这对我来说很有用……当你设置你的用户角色时,你只需要小心。 某些用户角色不能使用相同的用户名。

例如:

具有manager-gui角色的用户不应被授予manager-script或manager-jmx角色。 如果通过浏览器访问文本或jmx接口(例如,用于测试,因为这些接口仅用于非人类的工具),则之后必须关闭浏览器以终止会话。

具有admin-gui角色的用户不应被授予管理脚本角色。 如果通过浏览器访问文本界面(例如,为了测试,因为该界面仅用于非人类的工具),那么必须关闭浏览器以终止会话。

所以这就是我所做的,我能够查看所有三个服务器状态,管理器应用程序,主机管理器

我希望这可以帮助你..

 <tomcat-users> <role rolename="admin-gui"/> <role rolename="manager-gui" /> <user username="Your User Name" password="Your Password" roles="manager-gui, admin-gui"/> </tomcat-users> 

确保你关闭tomcat并重新启动它!

仅供参考:我遇到了同样的401错误(在Tomcat 7中),但它是基于从web上复制和粘贴tomcat-users.xml定义的完全不同的问题:有两种类型的双引号(不同的Unicode字符)看起来几乎相同,因此我几个小时忽略了这个问题!

一种双引号(工作的)是直型“(Unicode字符U + 0022),另一种(不起作用)是弯曲或卷曲或斜体或”右侧“型(Unicode字符U + 201D)。

用正确的双引号替换不正确的双引号后,我的登录工作完美无缺。

使我发现这个问题的线索是看着catalina.out,报告了以下错误(注意:在我的tomcat-users.xml文件中,我删除了所有评论,以确保我在处理纯XML语句的同时隔离该问题) :

 SEVERE: Parse Fatal Error at line 4 column 18: Open quote is expected for attribute "{1}" associated with an element type "rolename". 

更换不正确的引号后,我的登录工作完美无缺。