Search code examples
tomcat7tomcat-manager

Accessing Tomcat manager throws 404


I am using Tomcat 7.0.65.

Here is my 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

<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

But accessing any of the urls :

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

fails with "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 . Even curl fails with the same error.

Am I missing any configuration?


Solution

  • After much debugging, I found the real cause was the ManagerServlet was failing to get instantiated with the below security exception:

    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

    <!-- 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.