IceFaces Session Expiry causes an exception

99封情书 提交于 2019-12-25 08:48:36

问题


My IceFaces application crashes on session expiry. It's not showing the "User Session Expired" or "Network Connection Interrupted" message.

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

Asynchronous updates are on, and the jsp page has the <ice:outputConnectionStatus /> component.

Any ideas on how to stop this from happening?

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.

Thanks


回答1:


I had the same problem with RichFaces and this answer saved me :

jsf login times out

For a lot of turn around and stranges things I recommend to see this blog :

http://balusc.blogspot.com/

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;
    }
}

You also have to put this in faces-config.xml :

<application>
    <view-handler>com.spectotechnologies.jsf.viewhandler.AutoRegeneratorViewHandler</view-handler>
</application>


来源:https://stackoverflow.com/questions/5596489/icefaces-session-expiry-causes-an-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!