【问题标题】:IceFaces Session Expiry causes an exceptionIceFaces Session Expiry 导致异常
【发布时间】:2011-04-08 14:21:41
【问题描述】:

我的 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 的错误页面,但我已经全部注释掉了 - 没有运气。当重定向和错误处理都打开时,应用程序第一次会显示错误页面,然后在一段时间后重定向到“会话到期”页面。

谢谢

【问题讨论】:

    标签: jsf icefaces session-timeout


    【解决方案1】:

    我在 RichFaces 上遇到了同样的问题,这个答案救了我:

    jsf login times out

    对于很多转身和奇怪的事情,我建议看看这个博客:

    http://balusc.blogspot.com/

    这是我目前使用的代码:

    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>
    

    【讨论】:

    • 感谢您指出这一点。我已经使用涉及自定义错误 500 页面的 hack 实现了它(这显然是错误的方式)。稍后我会尝试实现此方法。
    猜你喜欢
    • 2014-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-03
    • 1970-01-01
    • 2017-03-23
    • 2011-06-08
    • 2017-02-16
    相关资源
    最近更新 更多