Http response code 404 means that the server is able to communicate with the client, but the resource being requested by the client cannot be located on the server. Before we get into how this is done on Tomcat, let's look at how this is done on a stand alone web server.
Stand Alone Web Server
Let's say a client requests bogus.html from a stand alone web server. If the web server does not contain a file named bogus.html, the web server will respond with http status code 404 - not found.
By default, nearly all web servers are configured to display 404 in the browser.
Or, you can check for 404 in the web servers access log.
2018-09-26 01:38:02 10.1.2.3 www.example.com GET "/bogus.html" HTTP/1.1 404
Stand Alone Tomcat Application Server
Similar to a stand alone web server, a stand alone Tomcat application server will respond with http status code 404 if the resource being requested does not exist. For example, let's say http://tomcat.com/example.html is requested directly from the Tomcat server. If example.html does not exist on the Tomcat server, then 404 will be returned. If example.html does exist on the Tomcat server, check catalina.out and catalina.log for issues.
Web Server + Proxy Pass + Tomcat
Diagnosing http response 404 is more tricky when a web server is configured to proxy requests to Tomcat. Typically, this is done using Proxy Pass.
For example, let's say www.example.com is a web server that fronts Tomcat. When a request is submitted to www.example.com, the web server will hand the request off to the proxy pass, and then the proxy pass will request the resource from Tomcat. If the web server and the proxy pass and Tomcat are properly configured, the requested resource will be sent to the client. In this example, index.jsp was requested, and was successfully sent to the client.
If 404 is being returned, you usually want to check the following.
- Ensure the web server is running
- Ensure nslookup can resolve the web server hostname to an IP address
- Ensure the Tomcat application server is running
- Ensure nslookup can resolve the Tomcat server hostname to an IP address
- Ensure the web server access log records the 404, as a way to confirm the request is getting to the web server
- Ensure the context root of the application in Tomcat is correct
- If possible, ensure you can request an HTML page directly from the web server
- Ensure 404 is not returned when requesting the app directly from Tomcat
- Ensure the proxy pass is properly configured