Seam Catch ViewExpiredException and redirect
andrewwheeler May 19, 2011 9:34 PMI want to redirect to page when a view has expired. I catch ViewExpiredException and the use the navigation handler to redirect. The problem is that weld tries to restore the current conversation during the redirect and fails. Is there a better way to redirect after exceptions are thrown?
public void viewExpiredHandler(@Handles CaughtException<ViewExpiredException> event) { event.handled(); messages.info("Your session has expired and you must login again."); redirect("login"); //=navigation.handleNavigation(facesContext, null, "login"); }
Caused by: java.lang.IllegalStateException: Unable to load current conversations from the associated request, something went badly wrong when associate() was called at org.jboss.weld.context.AbstractConversationContext.getCurrentConversation(AbstractConversationContext.java:410) [:20101031-0118] at org.jboss.weld.jsf.ConversationAwareViewHandler.getActionURL(ConversationAwareViewHandler.java:91) [:6.1.0-SNAPSHOT] at javax.faces.application.ViewHandlerWrapper.getActionURL(ViewHandlerWrapper.java:185) [:2.1.1-FCS] at com.sun.faces.application.view.MultiViewHandler.getRedirectURL(MultiViewHandler.java:381) [:2.1.1-FCS] at javax.faces.application.ViewHandlerWrapper.getRedirectURL(ViewHandlerWrapper.java:204) [:2.1.1-FCS] at javax.faces.application.ViewHandlerWrapper.getRedirectURL(ViewHandlerWrapper.java:204) [:2.1.1-FCS] at org.jboss.weld.jsf.ConversationAwareViewHandler.getRedirectURL(ConversationAwareViewHandler.java:134) [:6.1.0-SNAPSHOT] at javax.faces.application.ViewHandlerWrapper.getRedirectURL(ViewHandlerWrapper.java:204) [:2.1.1-FCS] at com.sun.faces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:166) [:2.1.1-FCS] at org.jboss.seam.faces.event.SeamPreNavigationHandler.handleNavigation(SeamPreNavigationHandler.java:48) [:3.0.0.Final] at org.jboss.weldx.faces.application.org$jboss$weld$beanProducerMethod-org$jboss$seam$faces$environment$NavigationHandlerProducermethod_getNavigationHandler()_$$_WeldClientProxy.handleNavigation(org$jboss$weld$beanProducerMethod-org$jboss$seam$faces$environment$NavigationHandlerProducermethod_getNavigationHandler()_$$_WeldClientProxy.java) [:] at volcanic.tephra.security.ExceptionHandler.redirect(ExceptionHandler.java:28) [:] at volcanic.tephra.security.ExceptionHandler.viewExpiredHandler(ExceptionHandler.java:52) [:]
This issue is similar to this one.