访问 Tomcat 经理抛出 404

Accessing Tomcat manager throws 404

我正在使用 Tomcat 7.0.65.

这是我的 tomcat-users.xml:

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

这是 server.xml

中的服务器领域片段
<Realm className="org.apache.catalina.realm.MemoryRealm" />

我可以访问以下 urls : [它第一次要求提供凭据]

http://localhost:8080/manager/status http://localhost:8080/manager/status/all

但是访问任何 urls :

http://localhost:8080/manager/text/sessions?path=/examples http://localhost:8080/manager/text/serverinfo

失败并显示“404 未找到”。以下是显示的错误消息:

The page you tried to access (/manager/text/sessions) does not exist.

The Manager application has been re-structured for Tomcat 7 onwards and some of URLs have changed. All URLs used to access the Manager application should now start with one of the following options:

/manager/html for the HTML GUI
/manager/text for the text interface
/manager/jmxproxy for the JMX proxy
/manager/status for the status pages
Note that the URL for the text interface has changed from "/manager" to "/manager/text".

You probably need to adjust the URL you are using to access the Manager application. However, there is always a chance you have found a bug in the Manager application. If you are sure you have found a bug, and that the bug has not already been reported, please report it to the Apache Tomcat team.

请注意,我正在以 /manager/text 的身份访问 url。甚至 curl 也因同样的错误而失败。

我是否缺少任何配置?

经过多次调试,我发现真正的原因是 ManagerServlet 未能实例化并出现以下安全异常:

java.lang.SecurityException: Restricted (ContainerServlet) class org.apache.catalina.manager.ManagerServlet

修复的方法是在TOMCAT_INSTALL_DIR/conf/context的"Context"部分设置"privileged=true"。xml

<!-- The contents of this file will be loaded for each web application -->
<Context privileged="true">

    <!-- Default set of monitored resources. If one of these changes, the    -->
    <!-- web application will be reloaded. 

在 conf/tomcat-users.xml 文件中提供以下角色。

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