简体   繁体   English

似乎已忽略javax.faces.application.ViewExpiredException

[英]javax.faces.application.ViewExpiredException seemingly ignored

I've put the following into my web.xml: 我将以下内容放入web.xml中:

    <error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/expiredIndex.jsf</location>
</error-page>
<error-page>
    <exception-type>java.lang.Throwable</exception-type>
    <location>/error.jsf</location>
</error-page>
<session-config>
    <session-timeout>1</session-timeout>
</session-config>

When I start my app, and wait for 1 minute, if I then attempt to interact with it (JSF 1.2, h:commandButton ) I get the error 当我启动我的应用程序并等待1分钟时,如果我尝试与其进行交互(JSF 1.2, h:commandButton ),则会收到错误消息

 SEVERE: Servlet.service() for servlet Faces Servlet threw exception
javax.faces.application.ViewExpiredException: viewId:/index.jsf - View /index.jsf could not be restored.
    at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:185)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
    at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:103)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
    at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
    at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
    at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Unknown Source)

Can someone tell me why it is the javax.faces.application.ViewExpiredException is not being picked up? 有人可以告诉我为什么它没有被javax.faces.application.ViewExpiredException拾取吗? I'm looking for the most basic expiry setup possible and surely that's all that is necessary in the web descriptor. 我正在寻找最基本的到期设置,并且肯定这是Web描述符中所需的全部。

Thanks 谢谢

EDIT 编辑

I now have in my web.xml the following: 现在,我的web.xml中包含以下内容:

<filter>
    <filter-name>Error</filter-name>
    <filter-class>myClient.ErrorFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>Error</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

    <error-page>
        <exception-type>javax.servlet.ViewExpiredException</exception-type>
        <location>/expiredIndex.jsf</location>
    </error-page>

(these entries are the last filter entries in the web.xml) and a new filter with the doFilter method as described in this post. (这些项是在web.xml最后过滤器的项)中,用如上述doFilter方法一个新的过滤柱。 What should be happening now is the rootCause should unwrap the ViewExpiredException which should thus redirect the user to my expiredIndex page when the servlet session times out. 现在应该发生的是rootCause应该解开ViewExpiredException,这样当Servlet会话超时时,应该将用户重定向到我的expiredIndex页面。 Instead I get a 500. I can't see what else to I need to do the correct redirect in this situation. 取而代之的是我得到500。在这种情况下,我看不到要做正确的重定向还需要做什么。 Help! 救命!

EDIT 2 编辑2

Error from the 500 is: 500中的错误是:

javax.faces.application.ViewExpiredException: viewId:/index.jsf - View /index.jsf could not be restored.
    com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:185)
    com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
    com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:103)
    com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
    org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
    org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
    org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
    org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
    prismClient.ErrorFilter.doFilter(Unknown Source)

which I guess is the standard one. 我猜这是标准的。

This is because the ViewExpiredException -as every other FacesException - is under the covers been wrapped in a ServletException . 这是因为ViewExpiredException其他FacesException ,都被包装在ServletException This one is been used to find matches in the declared error pages. 该代码用于在声明的错误页面中查找匹配项。 The closest match is java.lang.Throwable and thus the associated error page is been shown. 最接近的匹配是java.lang.Throwable ,因此显示了相关的错误页面。

If no match would have been found, then the root cause of the ServletException would have been unwrapped and a second pass through the declared error pages will be made with the unwrapped exception. 如果找不到匹配项,则将解开ServletException的根本原因,并将使用解开的异常再次遍历已声明的错误页面。 If you remove the java.lang.Throwable entry, you'll see that this will work. 如果删除java.lang.Throwable条目,您将看到它将起作用。

If you want to keep the java.lang.Throwable , then best what you can do is to create a Filter which unwraps any FacesException from the ServletException and rethrows it. 如果要保留java.lang.Throwable ,那么最好的办法是创建一个Filter ,该FacesExceptionServletException解包所有FacesException并将其重新抛出。

See also: 也可以看看:

Please see the blog posted on similar issue here : it's less cumbersome and quite effective. 请在此处查看有关类似问题的博客:它不那么麻烦,而且相当有效。 Be sure to include your "view-handler" tags within the "application" tags, doing this worked for me, cheers. 确保将您的“视图处理程序”标签包含在“应用程序”标签中,这对我很有效,干杯。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 强制使用javax.faces.application.ViewExpiredException测试应用程序 - Enforce javax.faces.application.ViewExpiredException for testing application JSF应用程序中带有JMeter的javax.faces.application.ViewExpiredException - javax.faces.application.ViewExpiredException with JMeter in JSF Application javax.faces.application.ViewExpiredException:无法还原视图 - javax.faces.application.ViewExpiredException: View could not be restored 升级到icefaces 1.7.2后的javax.faces.application.ViewExpiredException - javax.faces.application.ViewExpiredException after upgrading to icefaces 1.7.2 自定义NavigationHandler无法强制转换为javax.faces.application.ConfigurableNavigationHandler - Custom NavigationHandler cannot be cast to javax.faces.application.ConfigurableNavigationHandler JSF:我的应用程序中未引用 javax.faces.resources - JSF: javax.faces.resources is not referenced in my application NoSuchMethodError javax.faces.application.StateManager.saveView(Ljavax / faces / context / FacesContext;)Ljava / lang / Object; - NoSuchMethodError javax.faces.application.StateManager.saveView(Ljavax/faces/context/FacesContext;)Ljava/lang/Object; JavaFX,命令顺序(看似)被忽略 - JavaFX, order of commands (seemingly) ignored 运行Web应用程序 - 错误:包javax.faces.bean不存在 - run web application - error: package javax.faces.bean does not exist javax.faces.FacesException:没有文件上传 - javax.faces.FacesException: No file was uploaded
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM