我的IceFaces应用程序在会话到期时崩溃。它没有显示“用户会话已过期”或“网络连接中断”消息。
我的猜测是再次加载相同的页面,并且由于支持bean代码无法找到会话变量,因此会抛出以下异常:
exception
javax.servlet.ServletException: java.lang.Exception: javax.faces.FacesException: Problem in renderResponse: /main-template.jspx: User session has expired or it was invalidated.
root cause
java.lang.Exception: javax.faces.FacesException: Problem in renderResponse: /main-template.jspx: User session has expired or it was invalidated.
root cause
javax.faces.FacesException: Problem in renderResponse: /main-template.jspx: User session has expired or it was invalidated.
root cause
javax.el.ELException: /main-template.jspx: User session has expired or it was invalidated.
root cause
com.icesoft.faces.webapp.http.core.SessionExpiredException: User session has expired or it was invalidated.
root cause
java.lang.IllegalStateException: PWC2778: getAttribute: Session already invalidated
启用了异步更新,jsp页面包含<ice:outputConnectionStatus />
组件。
关于如何阻止这种情况发生的任何想法?
注意:我做了很多花哨的事情,比如重定向会话超时,并显示java.lang.Throwable的错误页面,但我已经全部评论了 - 没有运气。当重定向和错误处理都打开时,应用程序第一次显示错误页面,然后在一段时间后重定向到“会话到期”页面。
由于
答案 0 :(得分:1)
我在RichFaces遇到了同样的问题,这个答案救了我:
对于很多转身和奇怪的事情我建议看这个博客:
以下是我目前正在使用的代码:
package com.spectotechnologies.jsf.viewhandler;
import com.sun.facelets.FaceletViewHandler;
import java.io.IOException;
import javax.faces.application.ViewHandler;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
/**
* Source : https://stackoverflow.com/questions/231191/jsf-login-times-out
*
* This ViewHandler is used to remove the ViewExpiredException problem at login
* after the session is expired.
*
* @author Alexandre Lavoie
*/
public class AutoRegeneratorViewHandler extends FaceletViewHandler
{
public AutoRegeneratorViewHandler(ViewHandler p_oViewHandler)
{
super(p_oViewHandler);
}
@Override
public UIViewRoot restoreView(FacesContext p_oContext, String p_sViewID)
{
UIViewRoot oViewRoot = super.restoreView(p_oContext,p_sViewID);
if(oViewRoot == null)
{
// Work around Facelet issue
initialize(p_oContext);
oViewRoot = super.createView(p_oContext,p_sViewID);
p_oContext.setViewRoot(oViewRoot);
try
{
buildView(p_oContext,oViewRoot);
}
catch(IOException e)
{
e.printStackTrace();
}
}
return oViewRoot;
}
}
你还必须将它放在faces-config.xml中:
<application>
<view-handler>com.spectotechnologies.jsf.viewhandler.AutoRegeneratorViewHandler</view-handler>
</application>