ICEfaces
  1. ICEfaces
  2. ICE-1133

Unchecked exceptions are eaten by Blocking Servlet and bypass declarative exception handling rules

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.5.1
    • Fix Version/s: 1.6DR#6, 1.6
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      Operating System: Windows XP
      Platform: PC

      Description

      Not sure if the Servlet exception handling rules are still supposed to apply in
      JSF, but setting the following in web.xml doesn't have any effect in ICEfaces as
      exceptions are eaten:

      <error-page>
      <exception-type>java.lang.IllegalArgumentException</exception-type>
      <location>/error.jsp</location>
      </error-page>

      Several people in the forum
      (http://www.icefaces.org/JForum/posts/list/0/2893.page#15494) have requested
      some solution for a global error handling mechanism in ICEfaces.

        Issue Links

          Activity

          Hide
          Ken Fyten added a comment -

          Raised priority based on Philip's input.

          Show
          Ken Fyten added a comment - Raised priority based on Philip's input.
          Hide
          Ted Goddard added a comment -

          Some aspects of this may be fixed by ICE-1010. In general, however, errors during ICEfaces processing
          occur too late for the standard web.xml error-page to take effect (i.e. the HTTP header has already been
          modified).

          Show
          Ted Goddard added a comment - Some aspects of this may be fixed by ICE-1010 . In general, however, errors during ICEfaces processing occur too late for the standard web.xml error-page to take effect (i.e. the HTTP header has already been modified).
          Hide
          Ted Goddard added a comment -

          Accommodating generic error pages is difficult as described above. Recommend that we re-target this to
          1.6 or close as wontfix.

          Show
          Ted Goddard added a comment - Accommodating generic error pages is difficult as described above. Recommend that we re-target this to 1.6 or close as wontfix.
          Hide
          Patrick Corless added a comment -

          This used to work out of the box with 1.5 and several of our professional service application use this technique as well as the webmail project. If memory serves me correctly JSF handled the error page handling correctly once exception handling was improved in ICEfaces prior to the 1.5 release.

          I just did some testing with 1.5.3 and 1.6 dr 5 and had no problems getting the error handling to work. There are however a few quirks which I'm assuming are do the AJAX bridge. If your loading a page for the first time and an application initialization or component error occurs the error page will be shown as expected. However if an error is thrown via a bean accessor method or event, then the connection monitor will just spin away. A full page refresh will cause the error redirect to occur as normal.

          The preferred behavior would be for the bridge to respect the the error-page rules defined in the web.xml without having to refresh the page.

          Show
          Patrick Corless added a comment - This used to work out of the box with 1.5 and several of our professional service application use this technique as well as the webmail project. If memory serves me correctly JSF handled the error page handling correctly once exception handling was improved in ICEfaces prior to the 1.5 release. I just did some testing with 1.5.3 and 1.6 dr 5 and had no problems getting the error handling to work. There are however a few quirks which I'm assuming are do the AJAX bridge. If your loading a page for the first time and an application initialization or component error occurs the error page will be shown as expected. However if an error is thrown via a bean accessor method or event, then the connection monitor will just spin away. A full page refresh will cause the error redirect to occur as normal. The preferred behavior would be for the bridge to respect the the error-page rules defined in the web.xml without having to refresh the page.
          Hide
          Patrick Corless added a comment -

          Here is a simple web.xml snippet which will catch some commen application errors and forward a user to a friendly error page.

          This code can be added to any application to test the current error handling behavior, assuming error.html is created.

          <!-- All errors should jump back to the login screen -->
          <error-page>
          <exception-type>java.lang.ClassNotFoundException</exception-type>
          <location>/error.html</location>
          </error-page>
          <error-page>
          <exception-type>javax.servlet.jsp.JspException</exception-type>
          <location>/error.html</location>
          </error-page>
          <error-page>
          <exception-type>java.lang.NullPointerException</exception-type>
          <location>/error.html</location>
          </error-page>
          <error-page>
          <exception-type>javax.faces.FacesException</exception-type>
          <location>/error.html</location>
          </error-page>
          <error-page>
          <error-code>500</error-code>
          <location>/error.html</location>
          </error-page>

          Show
          Patrick Corless added a comment - Here is a simple web.xml snippet which will catch some commen application errors and forward a user to a friendly error page. This code can be added to any application to test the current error handling behavior, assuming error.html is created. <!-- All errors should jump back to the login screen --> <error-page> <exception-type>java.lang.ClassNotFoundException</exception-type> <location>/error.html</location> </error-page> <error-page> <exception-type>javax.servlet.jsp.JspException</exception-type> <location>/error.html</location> </error-page> <error-page> <exception-type>java.lang.NullPointerException</exception-type> <location>/error.html</location> </error-page> <error-page> <exception-type>javax.faces.FacesException</exception-type> <location>/error.html</location> </error-page> <error-page> <error-code>500</error-code> <location>/error.html</location> </error-page>
          Hide
          Patrick Corless added a comment -

          Mircea can you take a look at this. If you have any question please swing by.

          Show
          Patrick Corless added a comment - Mircea can you take a look at this. If you have any question please swing by.
          Hide
          Mircea Toma added a comment -

          The solution for this issue would be to also interpret HTTP standard messages (such as 404, 500 or 302) for the XMLHTTPRequest responses (right now the responses expect XML (UTF-8) valid bodies).

          Show
          Mircea Toma added a comment - The solution for this issue would be to also interpret HTTP standard messages (such as 404, 500 or 302) for the XMLHTTPRequest responses (right now the responses expect XML (UTF-8) valid bodies).
          Hide
          Mircea Toma added a comment -

          Handle HTTP 500 errors to enable servlet exception handling mechanism.
          Note:
          Depending were the exception occurs it may or may not propagate to the servlet container. For example if an exception will occur in a bean property modifier method the exception will be translated into an error message by the underlying JSF implementation.

          Show
          Mircea Toma added a comment - Handle HTTP 500 errors to enable servlet exception handling mechanism. Note: Depending were the exception occurs it may or may not propagate to the servlet container. For example if an exception will occur in a bean property modifier method the exception will be translated into an error message by the underlying JSF implementation.
          Hide
          Ken Fyten added a comment -

          If possible, we should extend this fix to extract any nested exceptions, as per the comment below from ICE-595:

          Which brings us to ICE-1133, which addresses catching Exceptions, and forwarding/redirecting to application developer specified pages. The problem is, if I catch the FileNotFoundException to send out the 404, then that will circumvent the Exception/500 code mechanism. To complicate matters, the FileNotFoundException is being wrapped in a FacesException, and the code is not pulling out the causing exception, so application developers can't, as of right now, actually specifically trap FileNotFoundException with the ICE-1133 method.

          Show
          Ken Fyten added a comment - If possible, we should extend this fix to extract any nested exceptions, as per the comment below from ICE-595 : Which brings us to ICE-1133 , which addresses catching Exceptions, and forwarding/redirecting to application developer specified pages. The problem is, if I catch the FileNotFoundException to send out the 404, then that will circumvent the Exception/500 code mechanism. To complicate matters, the FileNotFoundException is being wrapped in a FacesException, and the code is not pulling out the causing exception, so application developers can't, as of right now, actually specifically trap FileNotFoundException with the ICE-1133 method.
          Hide
          Ken Fyten added a comment -

          Existing behavior described in ICE-595 would be sufficient if we can extract nested exceptions.

          Show
          Ken Fyten added a comment - Existing behavior described in ICE-595 would be sufficient if we can extract nested exceptions.
          Hide
          Mircea Toma added a comment -

          So how to decide when to let the exception propagate to the servlet container, or extract the exception and re-throw it, and also what do we do when exceptions are nested multiple levels?
          In other words I'm not sure if extracting exceptions is the right thing to do, it is too late to make a decision of this kind at the framework level.

          Show
          Mircea Toma added a comment - So how to decide when to let the exception propagate to the servlet container, or extract the exception and re-throw it, and also what do we do when exceptions are nested multiple levels? In other words I'm not sure if extracting exceptions is the right thing to do, it is too late to make a decision of this kind at the framework level.
          Hide
          Mircea Toma added a comment -

          Closing this again. The previous comment explains why we cannot make the error handling mechanism work for all use cases.

          Show
          Mircea Toma added a comment - Closing this again. The previous comment explains why we cannot make the error handling mechanism work for all use cases.
          Hide
          Mark Collette added a comment -

          I'm not saying that we should always follow the getCause() chain for every Exception, just when it's a generic FacesException, which is inherently a wrapper exception.

          Show
          Mark Collette added a comment - I'm not saying that we should always follow the getCause() chain for every Exception, just when it's a generic FacesException, which is inherently a wrapper exception.
          Hide
          Mircea Toma added a comment -

          Apply "workaround" for the exceptions that are zealously captured & wrapped by the JSF implementations.

          Show
          Mircea Toma added a comment - Apply "workaround" for the exceptions that are zealously captured & wrapped by the JSF implementations.

            People

            • Assignee:
              Unassigned
              Reporter:
              Philip Breau
            • Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: