访问Tomcat管理器抛出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" />

我可以访问以下网址:[它第一次要求凭据]

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

但是访问任何网址:

http://localhost:8080/manager/text/sessions?path=/exampleshttp://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。即使卷曲也会出现同样的错误。

我是否缺少任何配置?

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

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

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

<!-- 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"/>

最新更新