2012-11-08 153 views
0

可能重复:
JSF 1.2 Exception HandlingJSF会话超时&异常处理

在web.xml,我不得不会话配置如下

<session-config> 
    <session-timeout>2</session-timeout> 
</session-config> 

,我还有一个错误页面定义如下

<error-page> 
    <exception-type>javax.faces.application.ViewExpiredException</exception-type> 
    <location>/sc00/ErrorPage.jsp</location> 
</error-page> 

,并在应用程序超时的,我不能直接到错误页面,它说

SRVE0260E: The server cannot use the error page specified for your application to handle the Original Exception printed below. 


Original Exception: 
Error Message: javax.servlet.ServletException: /sc40/NewContract.facesNo saved   view  state could be found for the view identifier: /sc40/NewContract.faces 
Error Code: 500 
Target Servlet: Faces Servlet 
Error Stack: 
javax.faces.application.ViewExpiredException: /sc40/NewContract.facesNo saved view  state could be found for the view identifier: /sc40/NewContract.faces 
at org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:128) 
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:171) 
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) 
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189) 
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1147) 
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:722) 
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:449) 
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178) 
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1020) 
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3639) 
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304) 
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:950) 
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1659) 
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195) 
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452) 
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511) 
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305) 
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:276) 
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214) 
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113) 
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165) 
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217) 
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161) 
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138) 
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204) 
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775) 
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905) 
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1648) 




Error Page Exception: 
Error Message: java.lang.RuntimeException: FacesContext not found 
Error Code: 0 
Target Servlet: 
Error Stack: 
java.lang.RuntimeException: FacesContext not found 
at javax.faces.webapp.UIComponentClassicTagBase.getFacesContext (UIComponentClassicTagBase.java:324) 
at javax.faces.webapp.UIComponentClassicTagBase.setJspId(UIComponentClassicTagBase.java:226) 
at com.ibm._jsp._ErrorPage._jspx_meth_f_view_0(_ErrorPage.java:416) 
at com.ibm._jsp._ErrorPage._jspService(_ErrorPage.java:103) 
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:99) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668) 
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1147) 
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:722) 
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:449) 
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178) 
at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:122) 
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:205) 
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1020) 
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:1382) 
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:191) 
at com.ibm.ws.webcontainer.webapp.WebApp.sendError(WebApp.java:3143) 
at com.ibm.ws.webcontainer.webapp.WebApp.handleException(WebApp.java:3669) 
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3650) 
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304) 
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:950) 
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1659) 
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195) 
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452) 
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511) 
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305) 
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:276) 
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214) 
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113) 
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165) 
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217) 
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161) 
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138) 
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204) 
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775) 
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905) 
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1648) 
                         and i am using jsf1.2 

我怎么能直接例外的errorPage.jsp,我不想超时由jsf处理异常,因为我需要关闭浏览器并重新启动 - 重新执行。所以请建议我一种处理这种异常的方法,我正在使用jsf1.2

+0

不知道这是JSF 1.2或WebSphere具体,但尽量指定'/sc00/ErrorPage.faces'作为错误页面位置(至少,它必须匹配FacesServlet的servlet映射)。 – BalusC

+0

我不明白你的错误页面位置是什么意思,我可以在哪里设置它。 – ylnsagar

+0

恩,正如我所说,但随后在XML中:''。 – BalusC

回答

0

由于某种原因,上面的标签在web.xml中不起作用,试图找出原因,但不能。

为了解决我写了一个监听器类如下

<lifecycle> 
<phase-listener>com.bcbsks.me.sc00.listeners.ErrorPageNavigationListener</phase- listener> 
</lifecycle> 

在这里,在“Facesconfig.xml”注册的监听器类的问题“ErrorPageNAvigationListener是监听器类和代码的Listener类如下: 。

public class ErrorPageNavigationListener implements PhaseListener{ 

/** 
* 
*/ 
private static final long serialVersionUID = 1L; 

String HOME_PAGE = "../sc00/TimeOutPage.faces"; 

@Override 
public void afterPhase(PhaseEvent event) { 
    FacesContext facesContext = event.getFacesContext(); 
    if(facesContext.getViewRoot()==null){ 
     try{ 
      facesContext.getExternalContext().redirect(HOME_PAGE);     
      facesContext.responseComplete(); 

     } catch (IOException e){ 
      e.printStackTrace(); 
     } 
    } 
} 

@Override 
public void beforePhase(PhaseEvent event) { 
    // TODO Auto-generated method stub 

} 

@Override 
public PhaseId getPhaseId() { 
    // TODO Auto-generated method stub 
    return PhaseId.RESTORE_VIEW; 

} 
} 

的HOME_PAGE是路径错误页面,它为我工作得很好。