1

I have a web application running in WebSphere Application Server 9.0.x, and I integrate the Shiro security framework to the web application recently.

web.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         metadata-complete="true">
    <display-name>xxxx</display-name>

    <listener>
         <listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
    </listener>

    <filter>
        <filter-name>ShiroFilter</filter-name>
        <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>ShiroFilter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
        <dispatcher>ERROR</dispatcher>
    </filter-mapping>

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>

However, after I restart the server and access my index.jsp, those static resources which not exist in the server will generate an error message with a FileNotFoundException stack trace per each not existed resources in the SystemOut.log:

com.ibm.ws.webcontainer.filter.FilterInstanceWrapper doFilter SRVE8109W: Uncaught exception thrown by filter ShiroFilter: java.io.FileNotFoundException: SRVE0190E: File not found: /js/test.js
...
...
...

I checked the IBM document and know that I can add a custom property (com.ibm.ws.webcontainer.suppressLoggingFileNotFoundExceptions) to suppress the FileNotFoundException and output a warning message in the SystemOut.log instead. (Reference: https://www.ibm.com/docs/en/was/9.0.5?topic=configuration-web-container-custom-properties#com.ibm.ws.webcontainer.suppressLoggingFileNotFoundExceptions)

But my question is that, why the FileNotFoundException will shown in the SystemOut.log after I add the filter config in web.xml. Before this, there is not this kind of issue (error message) in SystemOut.log although static resources not exist in the server.

Why FileNotFoundException generate in SystemOut.log after add filter config in web.xml

Carson
  • 21
  • 2
  • Can you add a bit of the stack trace of the exception (and, if there's a nested "Caused by" exception, the message and top few frames of that as well)? Feel free to obfuscate your internal, packages/classes/methods, but at the very least it would be good to know who is throwing that exception, whether it's the server or Shiro or your own code. – Jarid Apr 15 '23 at 15:28
  • If these resources do not exist anywhere what would you expect instead of 404? Where is this `/js/test.js` resource? – Gas Apr 15 '23 at 18:27
  • @Gas Actually, if these resources do not exist anywhere, FileNotFoundException will not generate in the SystemOut.log before I add filter config in web.xml – Carson Apr 16 '23 at 08:51
  • Because then you will get standard 404 errror – Gas Apr 16 '23 at 18:54

0 Answers0