简体   繁体   English

访问Tomcat管理器抛出404

[英]Accessing Tomcat manager throws 404

I am using Tomcat 7.0.65.我正在使用 Tomcat 7.0.65。

Here is my tomcat-users.xml:这是我的 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"/>

Here is the server realm snippet in server.xml这是 server.xml 中的服务器领域片段

<Realm className="org.apache.catalina.realm.MemoryRealm" />

I can access the below urls : [It asks for the credentials for the first time]我可以访问以下网址:[首次要求提供凭据]

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

But accessing any of the urls :但是访问任何网址:

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

fails with "404 Not found".失败并显示“404 Not found”。 Below is the displayed error message:下面是显示的错误信息:

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.

Note that I am accessing the url as /manager/text .请注意,我以 /manager/text 的身份访问该网址。 Even curl fails with the same error.甚至 curl 也因相同的错误而失败。

Am I missing any configuration?我缺少任何配置吗?

After much debugging, I found the real cause was the ManagerServlet was failing to get instantiated with the below security exception:经过多次调试,我发现真正的原因是 ManagerServlet 未能通过以下安全异常进行实例化:

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

The way to fix is to set "privileged=true" in the "Context" section in TOMCAT_INSTALL_DIR/conf/context.xml解决方法是在 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"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM