问题描述
我的IceFaces应用程序在会话到期时崩溃.它没有显示用户会话已过期"或网络连接中断"消息.
My IceFaces application crashes on session expiry. It's not showing the "User Session Expired" or "Network Connection Interrupted" message.
我的猜测是再次加载同一页面,并且由于支持bean代码无法找到会话变量,因此它引发以下异常:
My guess is the same page is loaded again, and since the backing bean code cannot find the session variables, it throws the following exception:
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 />
组件.
Asynchronous updates are on, and the jsp page has the <ice:outputConnectionStatus />
component.
关于如何阻止这种情况发生的任何想法?
Any ideas on how to stop this from happening?
注意:我正在做很多有趣的事情,例如在会话超时时重定向,并显示java.lang.Throwable的错误页面,但我已经将所有内容注释掉了-没运气.重定向和错误处理都打开时,应用程序第一次显示错误页面,然后过一会儿重定向到会话过期"页面.
Note: I was doing a lot of fancy stuff, like redirecting on session timeout, and displaying error pages for java.lang.Throwable, but I've commented it all out - without luck. When both redirection and error-handling were switched on, on the first time the application would show the error page, then after a while redirect to "session-expiry" page.
谢谢
推荐答案
我在RichFaces上遇到了同样的问题,这个答案救了我:
I had the same problem with RichFaces and this answer saved me :
对于很多转折和奇怪的事情,我建议去看这个博客:
For a lot of turn around and stranges things I recommend to see this blog :
这是我当前正在使用的代码:
Here is the code I'm currently using :
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中:
You also have to put this in faces-config.xml :
<application>
<view-handler>com.spectotechnologies.jsf.viewhandler.AutoRegeneratorViewHandler</view-handler>
</application>
这篇关于IceFaces会话到期会导致异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!