RedirectException being caught from page begin rendering method (in exception 
page) as an application exception rather than causing the redirect
------------------------------------------------------------------------------------------------------------------------------------------------

         Key: TAPESTRY-671
         URL: http://issues.apache.org/jira/browse/TAPESTRY-671
     Project: Tapestry
        Type: Bug
    Reporter: Leonardo Quijano Vincenzi
    Priority: Minor


As in TAPESTRY-647, my application is catching a RedirectException when I try 
to redirect from the Exception page.
Such as this:

    /** @see PageBeginRenderListener#pageBeginRender(PageEvent) */
    public void pageBeginRender(PageEvent event) {
        Throwable value = getException();

        if((value instanceof PageNotFoundException)) {
            WebRequest request = getWebRequest();
            String activationPath = request.getActivationPath();
            
            redirectToExternalPage(event.getRequestCycle(), 
getExternalService(), "PageNotFound", activationPath);
   }

redirectToExternalPage() just gets the appropiate link and throw() a 
RedirectException.
This is the stack trace:


org.apache.tapestry.RedirectException
   redirectLocation: /sigep/Index.html
com.dtqsoftware.utils.web.WebUtils.redirectToPage(WebUtils.java:62)
com.dtqsoftware.sigep.web.pages.Exception.pageBeginRender(Exception.java:83)
org.apache.tapestry.AbstractPage.firePageBeginRender(AbstractPage.java:478)
org.apache.tapestry.AbstractPage.renderPage(AbstractPage.java:268)
org.apache.tapestry.engine.RequestCycle.renderPage(RequestCycle.java:368)
org.apache.tapestry.services.impl.ResponseRendererImpl.renderResponse(ResponseRendererImpl.java:71)
$ResponseRenderer_1069ac67711.renderResponse($ResponseRenderer_1069ac67711.java)
$ResponseRenderer_1069ac67710.renderResponse($ResponseRenderer_1069ac67710.java)
org.apache.tapestry.error.ExceptionPresenterImpl.presentException(ExceptionPresenterImpl.java:46)
$ExceptionPresenter_1069ac676ff.presentException($ExceptionPresenter_1069ac676ff.java)
$ExceptionPresenter_1069ac676fe.presentException($ExceptionPresenter_1069ac676fe.java)
org.apache.tapestry.engine.AbstractEngine.activateExceptionPage(AbstractEngine.java:121)
org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:280)
org.apache.tapestry.services.impl.InvokeEngineTerminator.service(InvokeEngineTerminator.java:60)

....
etc()

Following the code... seems the exception propagates down to 
ExceptionPresenterImpl. There it's nested in a more general 
ApplicationException, thereby losing its RedirectException status:

    public void presentException(IRequestCycle cycle, Throwable cause)
    {
        try
        {
            IPage exceptionPage = cycle.getPage(_exceptionPageName);

            exceptionPage.setProperty("exception", cause);

            cycle.activate(exceptionPage);

            _responseRenderer.renderResponse(cycle);
        }
        catch (Throwable ex)
        {
            // Worst case scenario. The exception page itself is broken, leaving
            // us with no option but to write the cause to the output.

            _requestExceptionReporter.reportRequestException(ErrorMessages
                    .unableToProcessClientRequest(cause), cause);

            // Also, write the exception thrown when redendering the exception
            // page, so that can get fixed as well.

            _requestExceptionReporter.reportRequestException(ErrorMessages
                    .unableToPresentExceptionPage(ex), ex);

            // And throw the exception.

            throw new ApplicationRuntimeException(ex.getMessage(), ex);
        }

        if (_verbose)
            _requestExceptionReporter.reportRequestException(ErrorMessages
                    .unableToProcessClientRequest(cause), cause);
    }



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to