Problem(Abstract)
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.
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:
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:
- Click Servers -> Server Types -> Websphere Application Server -> <server_name> -> Web Container Settings -> Web Container
- Under additional settings click on custom properties
- On custom properties page, click New and then enter "com.ibm.ws.webcontainer.invokefilterscompatibility" as the property name and "true" as the value
- Save the update and restart the server
댓글 없음:
댓글 쓰기