MyFaces Core
  1. MyFaces Core
  2. MYFACES-2214

Cannot use custom error handler (param org.apache.myfaces.ERROR_HANDLER) due to bug in FacesServlet

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.2, 1.2.3, 1.2.4, 1.2.5, 1.2.6
    • Fix Version/s: 1.2.7
    • Component/s: JSR-252
    • Labels:
      None
    • Environment:
      JRE 1.6.11, Tomcat 6.0.18, myfaces-1.2.6

      Description

      With MYFACES-1685 the possiblity to set a custom error handler has been introduced with the following init parameters:

      org.apache.myfaces.ERROR_HANDLING = true (default)
      org.apache.myfaces.ERROR_HANDLER = <class name>

      Alas, the current implementation of FacesServlet has a small but fatal bug, which makes using a custom error handler completely unusable:

      In the private method handleQueuedExceptions(FacesContext) in lines 203-204 it says:

      Method m = clazz.getMethod("handleExceptionList", new Class[]

      {FacesContext.class,Exception.class}

      );
      m.invoke(errorHandler, new Object[]

      {facesContext, li});

      This code finds a method with signature handleExceptionList(FacesContext,Exception), but invokes it with (FacesContext,List) parameter instances. This leads to an exception: IllegalArgumentException: argument type mismatch

      The correct code would be:

      Method m = clazz.getMethod("handleExceptionList", new Class[]{FacesContext.class,List.class});
      m.invoke(errorHandler, new Object[]{facesContext, li}

      );

      Because of this bug it is impossible to create a custom error handler for exceptions collected in the update model phase. I am unable to see a workaround.

        Issue Links

          Activity

          Hide
          Leonardo Uribe added a comment -

          Changed to:

          Method m = clazz.getMethod("handleExceptionList", new Class[]

          {FacesContext.class,List.class}

          );
          m.invoke(errorHandler, new Object[]

          {facesContext, li}

          );

          as suggested.

          Show
          Leonardo Uribe added a comment - Changed to: Method m = clazz.getMethod("handleExceptionList", new Class[] {FacesContext.class,List.class} ); m.invoke(errorHandler, new Object[] {facesContext, li} ); as suggested.
          Hide
          Dirk Möbius added a comment -

          Yes, this works like a charm.

          Thanks a lot! That was really fast!

          Show
          Dirk Möbius added a comment - Yes, this works like a charm. Thanks a lot! That was really fast!

            People

            • Assignee:
              Leonardo Uribe
              Reporter:
              Dirk Möbius
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development