2011-04-08 34 views
0

My IceFaces應用程序在會話過期時崩潰。它沒有顯示「用戶會話過期」或「網絡連接中斷」消息。IceFaces Session Expiry導致例外

我的猜測是相同的頁面再次加載,因爲支持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的顯示錯誤頁面,但我評論了這一切 - 沒有運氣。當重定向和錯誤處理都打開時,應用程序第一次顯示錯誤頁面,然後過一會兒重定向到「session-expiry」頁面。

感謝

回答

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> 
+0

感謝您指出了這一點。我已經使用涉及自定義Error 500頁面的黑客(這顯然是錯誤的方式)實現了它。我會稍後嘗試實施此方法。 – Ali 2011-04-13 04:56:09