You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Richard Wallace <rw...@thewallacepack.net> on 2005/07/06 19:00:32 UTC

NavigationHandler ignoring responseComplete()

Hey all,

I'm working on redirecting a user to the page they requested after 
successfully authenticating.  To do this I use the 
ExternalContext.redirect() method to redirect to a URL that is stored in 
the session when they try and access a page but aren't logged in and are 
redirected.  As I understand the JSF specs, this method should call the 
FacesContext.responseComplete() method and JSF shouldn't try and do 
anymore with the response.  I also have a navigation rule defined for 
the case when a user hasn't tried to access something before 
authenticating so they get directed to a default pre-login page.

It seems that when a user has tried to access a restricted page without 
authentication the navigation handler is ignoring the call to 
FacesContext.responseComplete() and trying to do another redirect to the 
default pre-login page.  This results in the following exception 
(somewhat shortened for brevity):

java.lang.IllegalStateException
        at 
org.apache.coyote.tomcat5.CoyoteResponseFacade.sendRedirect(CoyoteResponseFacade.java:352)
        at 
org.apache.myfaces.context.servlet.ServletExternalContextImpl.redirect(ServletExternalContextImpl.java:479)
        at 
org.apache.myfaces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:179)
        at 
org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:85)
        at javax.faces.component.UICommand.broadcast(UICommand.java:106)
        at 
javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:110)
        at 
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:184)
        at 
org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:271)
        at 
org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:102)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:109)
        at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
        at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)

Is this a bug in the NavigationHandler implementation?  I'm using 
MyFaces 1.0.9.

I tried returning null from my action handler rather than something 
matching a rule to try and bypass the NavigationHandler, but that 
resulted in the following exception (again, shortened for brevity):

java.lang.IllegalStateException: Cannot forward after response has been 
committed
        at 
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:324)
        at 
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
        at 
org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:405)
        at 
org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:277)
        at 
org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:300)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:110)
        at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
        at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)

Any ideas?

Thanks,
Rich