Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-3107

Custom error page not rendered (jsp templates)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 4.3
    • 4.0.3, 4.1.4, 4.2.3, 4.3
    • templating
    • None

    Description

      The problem occurs when an exception (eg: NullPointerException) is thrown during the rendering of a page with jsp template: if a custom error page (also with jsp template) has been configured in web.xml, it does not display (blank page instead).

      Example of web.xml configuration:

      <error-page>
        <exception-type>java.lang.Throwable</exception-type>
        <location>/myapp/errors/error.html</location>
      </error-page>
      

      The MgnlMainFilter receives the request for the error page, but immediatly bypasses it, due to voter "dontDispatchOnForwardAttribute":

      2010-03-04 10:57:32,437 DEBUG info.magnolia.cms.filters.MgnlMainFilter MgnlMainFilter.java(doFilter:93) Handling URI: /myapp/errors/error.html - Path info: null
      2010-03-04 10:57:32,437 DEBUG info.magnolia.voting.DefaultVoting DefaultVoting.java(vote:58) voter [dontDispatchOnForwardAttribute: ] fired 1
      2010-03-04 10:57:32,437 DEBUG info.magnolia.voting.DefaultVoting DefaultVoting.java(vote:62) highest vote is now 1
      

      I found that the dontDispatchOnForwardAttribute voter prevents the rendering of the error page because just before starting the rendering of the original page (the one that throws the Exception) an attribute DONT_DISPATCH_ON_FORWARD_ATTRIBUTE was put in request by the JspTemplateRenderer:

      // set this attribute to avoid a second dispatching of the filters
      request.setAttribute(DontDispatchOnForwardAttributeVoter.DONT_DISPATCH_ON_FORWARD_ATTRIBUTE, Boolean.TRUE);
      

      JspTemplateRenderer should remove that attribute when catching the exception: this would fix the problem.
      See attached patch: JspTemplateRenderer.patch

      Checklists

        Acceptance criteria

        Attachments

          Issue Links

            Activity

              People

                fgiust Fabrizio Giustina
                diegoschivo Diego Schivo
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:

                  Checklists

                    Bug DoR
                    Task DoD