I have a REST application deployed in FUSE ESB 6.1. There are many services exposed to the external clients. The issue is, Sometimes clients receive HTTP 404 Not Found with the following html.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 404 Not Found </title>
</head>
<body>
<h2>HTTP ERROR: 404</h2>
<p>Problem accessing /context/api/service1. Reason:
<pre> Not Found</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>
</body>
</html>
I can see this is due to a wrong service name.
But i can't find any related log entries in server logs. Is there any option to see these Jetty Error details in the REST server? Possibly any Jetty logs ?
As with any servlet container, you can redirect 404 errors to a JSP, servlet, whatever, and simply log the URL yourself.
From the Jetty documentation :
Error code example:
<error-page> <error-code>404</error-code> <location>/jspsnoop/ERROR/404</location> </error-page>
Exception example:
<error-page> <exception-type>java.io.IOException</exception-type> <location>/jspsnoop/IOException</location> </error-page>
You can also catch 404 errors that happen outside your application context:
Server level 404 error
It is possible to get a page not found when a request is made to the server for a resource that is outside of any registered contexts. As an example, you have a domain name pointing to your public server IP, yet no context is registered with Jetty to serve pages for that domain. As a consequence, the server, by default, gives a listing of all contexts running on the server.
One of the quickest ways to avoid this behavior is to create a catch all context. Create a "root" web app mapped to the "/" URI, and use the index.html redirect to whatever place with a header directive.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.