Jetty
  1. Jetty
  2. JETTY-379

declared error-page not called for a JasperException

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.1.4
    • Component/s: None
    • Labels:
      None
    • Environment:
      win xp - eclipse - maven mojo
    • Number of attachments :
      0

      Description

      I've a general error-page which handles all types of Exceptions (e.g. JasperException -> shows een the line with the error)

      • I declare an error-page in web.xml like this
        	<error-page>
        		<exception-type>org.apache.jasper.JasperException</exception-type>
        		<location>/error-page.jsp</location>
        	</error-page>
        

      This page is never called on an exception org.apache.jasper.JasperException: /WEB-INF/classes/de/dwpbank/wpdirect/vienna/ug0001samples/uc0004layout/pages/layout1.jsp(13,6) No such tag ro in the tag library imported with prefix v

      Reason:

      • The Throwable above will be set to Dispatcher.ForwardAttributes by the key javax.servlet.error.exception but this method suppresses all keys starting on "javax.servlet", so the ErrorPageErrorHandler can never forward to it !

      Why does the Dispatcher.ForwardAttributes.setAttribute(...) does that ?

        Activity

        Hide
        Greg Wilkins added a comment -

        Can you try to reproduce this with the latest from svn head?

        I have modfied the test webapp to try to reproduce, but I cannot

        If you hit http://jetty.mortbay.org:8080/test/dispatch/forward/dump/ex1

        you will see it working correctly on our public server.

        The ForwardAttributes class does not suppress all javax.servlet attributes, as it
        calls _attr.setAttribute if need be. Besides, this is not the path that exception
        attributes are set.

        thanks

        Show
        Greg Wilkins added a comment - Can you try to reproduce this with the latest from svn head? I have modfied the test webapp to try to reproduce, but I cannot If you hit http://jetty.mortbay.org:8080/test/dispatch/forward/dump/ex1 you will see it working correctly on our public server. The ForwardAttributes class does not suppress all javax.servlet attributes, as it calls _attr.setAttribute if need be. Besides, this is not the path that exception attributes are set. thanks
        Hide
        Andreas Knuth added a comment -

        I tested your sample http://localhost:8080/test/dispatch/forward/dump/ex1 with jetty 6.0.X because of JDK 1.4 !

        I also changed the pom dependencies of your sample to:

        		<dependency>
        			<groupId>javax.servlet</groupId>
        			<artifactId>servlet-api</artifactId>
        			<version>2.4</version>
        		</dependency>
        		<dependency>
        			<groupId>jspapi</groupId>
        			<artifactId>jsp-api</artifactId>
        			<version>2.0</version>
        		</dependency>
        		<dependency>
        			<groupId>org.mortbay.jetty</groupId>
        			<artifactId>jetty-util</artifactId>
        			<version>${project.version}</version>
        		</dependency>
        		<dependency>
        			<groupId>org.mortbay.jetty</groupId>
        			<artifactId>jetty</artifactId>
        			<version>${project.version}</version>
        			<scope>test</scope>
        		</dependency>
        

        and the result was the same as described above:

        -> runs ServletHandler.handle(...)
        --> runs in the catch(Exception e) block
        --> sets request.setAttribute(ServletHandler.__J_S_ERROR_EXCEPTION_TYPE,th.getClass());
        --> runs _attributes.setAttribute(name, value); with _attributes = Dispatcher$ForwardAttributes
        -->because of key.startsWith("javax.servlet.") this one will not be written into the map
        .....
        --> runs ErrorPageErrorHandler.handle(...)
        --> _errorPages are declared (see web.xml)
        --> but (Class)request.getAttribute(ServletHandler.__J_S_ERROR_EXCEPTION_TYPE) and (Integer)request.getAttribute(ServletHandler.__J_S_ERROR_STATUS_CODE) is null

        --> no FORWARD to the declared error_page

        sorry that i cannot run the latest svn head code but I as interpret head code nothing has changed in that code region ...

        thanks for help

        Show
        Andreas Knuth added a comment - I tested your sample http://localhost:8080/test/dispatch/forward/dump/ex1 with jetty 6.0.X because of JDK 1.4 ! I also changed the pom dependencies of your sample to: <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.4</version> </dependency> <dependency> <groupId>jspapi</groupId> <artifactId>jsp-api</artifactId> <version>2.0</version> </dependency> <dependency> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-util</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty</artifactId> <version>${project.version}</version> <scope>test</scope> </dependency> and the result was the same as described above: -> runs ServletHandler.handle(...) --> runs in the catch(Exception e) block --> sets request.setAttribute(ServletHandler.__J_S_ERROR_EXCEPTION_TYPE,th.getClass()); --> runs _attributes.setAttribute(name, value); with _attributes = Dispatcher$ForwardAttributes -->because of key.startsWith("javax.servlet.") this one will not be written into the map ..... --> runs ErrorPageErrorHandler.handle(...) --> _errorPages are declared (see web.xml) --> but (Class)request.getAttribute(ServletHandler.__J_S_ERROR_EXCEPTION_TYPE) and (Integer)request.getAttribute(ServletHandler.__J_S_ERROR_STATUS_CODE) is null --> no FORWARD to the declared error_page sorry that i cannot run the latest svn head code but I as interpret head code nothing has changed in that code region ... thanks for help
        Jan Bartel made changes -
        Field Original Value New Value
        Assignee Jan Bartel [ janb ]
        Hide
        Jan Bartel added a comment -

        Hi Andreas,

        I have not been able to reproduce this problem at all under jetty 6.1.4. Can you try with jetty 6.1.4? BTW in my testing, running with jdk1.4 (and therefore using jsp-2.0) produces exactly the same (correct) result as running under jdk1.5 (therefore jsp-2.1).

        regards
        Jan

        Show
        Jan Bartel added a comment - Hi Andreas, I have not been able to reproduce this problem at all under jetty 6.1.4. Can you try with jetty 6.1.4? BTW in my testing, running with jdk1.4 (and therefore using jsp-2.0) produces exactly the same (correct) result as running under jdk1.5 (therefore jsp-2.1). regards Jan
        Hide
        Andreas Knuth added a comment -

        Hi Jan,

        sometimes it's a good idea to use the latest version --> all Problems are gone - thanks for help

        I was not sure that jetty 6.1.X can be run on jdk 1.4 ... so I used jetty 6.0.X

        regards,

        Andreas

        Show
        Andreas Knuth added a comment - Hi Jan, sometimes it's a good idea to use the latest version --> all Problems are gone - thanks for help I was not sure that jetty 6.1.X can be run on jdk 1.4 ... so I used jetty 6.0.X regards, Andreas
        Andreas Knuth made changes -
        Resolution Fixed [ 1 ]
        Fix Version/s 6.1.4 [ 13517 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 6.0.1 [ 12921 ]
        Jan Bartel made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Jan Bartel
            Reporter:
            Andreas Knuth
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: