IBM Support

Servlet Error 404: Websphere application servlet filter – resource URLredirection

Troubleshooting


Problem

You encounter Error 404: Servlet not found error upon accessing the J2EE application index or home page after deploying the application on Websphere Application Server.

Symptom

The browser displays either a Page cannot be found or Error 404: Servlet not found error

Cause

WebSphere 6.1.0.5 and above checks if a URL is mapped to a servlet or a file before it puts a request through the filter chain.

Consider an example URL – http://<application_name>/servlet/<resource.html_jsp>

As we do not have a servlet or a file that is mapped to a URL, WebSphere 6.1.0.5 sends a 404 to the user before giving the UrlRewrite filter a chance to redirect a URL to the correct place.

Environment

This error appears across multiple platforms such as AIX, Windows and Linux. It also appears across different versions of Websphere Application Server 6.1.0.5 onwards.

Resolving The Problem

Use a custom servlet filter with J2EE applications to map the index page from one URL to another IRL that points to a specific resource that you wish to load on loading the starting URL of the application.

For instance, you can map URLs that start with index.html to the index.html/another_directory/new_resource.jsp. Without enabling the com.ibm.ws.webcontainer.invokeFiltersCompatibility custom property, the Web container does not call any custom servlet filters.

With this custom property, the Web container calls custom servlet filters before looking for welcome files. Also, if the Web container cannot find a resource, it calls the custom servlet filters before creating a FileNotFoundException exception or a an Error 404. This change enables the Web container to verify whether the custom servlet filters modify the path to a resource.

To make the filter invoke on a request without a servlet mapping you should be able to do the following in the WebSphere Admin Console:

  1. Click Servers -> Server Types -> Websphere Application Server -> <server_name> -> Web Container Settings -> Web Container
  2. Under additional settings click on custom properties
  3. On custom properties page, click New and then enter "com.ibm.ws.webcontainer.invokefilterscompatibility" as the property name and "true" as the value
  4. Save the update and restart the server

[{"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Servlet Engine\/Web Container","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"7.0;6.1.1;6.1","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
15 June 2018

UID

swg21570105