升级到jsf2后ViewExpiredException

发布于 2024-10-31 11:00:10 字数 374 浏览 2 评论 0原文

我们最近将主要平台从 jsf 1.2 升级到 2.0。升级后,我们每小时都会收到几个 ViewExpiredException 错误。从阅读该主题来看,这似乎是会话过期时的预期异常,但是我们检查了访问日志,即使在某些情况下请求仅相隔 5 分钟,我们也会收到这些异常。

我的问题如下:

1)除了会话过期之外,还有哪些条件可能导致ViewExpiredException?

2) 我们记录的异常不包含有关导致异常的确切条件的详细信息(会话丢失、会话损坏、无法恢复特定组件)。有没有办法引入额外的日志记录来找出在每种情况下触发此异常的非常具体的情况?

莫贾拉2.0.4-b09 雄猫6 使用 Memcached 会话管理器进行会话复制

感谢任何帮助。谢谢!

We recently upgraded a major platform from jsf 1.2 to 2.0. After upgrading we're getting several ViewExpiredException errors each hour. From reading up on the topic it seems that this is an expected exception when sessions expire, however we've reviewed the access logs and we are getting these exceptions even when requests are only 5 minutes apart in some cases.

My questions are as follows:

1) Other than session expiration, what other conditions might cause ViewExpiredException?

2) The exception we're logging doesn't contain much detail about the exact condition that is causing the exception (missing session, corrupt session, unable to restore a particular component). Is there a way to introduce additional logging to find out the very specific situation that is triggering this exception in each case?

Mojarra 2.0.4-b09
Tomcat 6
Using Memcached Session Manager for session replication

Any help is appreciated. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北陌 2024-11-07 11:00:10

除了会话过期之外,还有哪些其他情况可能导致 ViewExpiredException?

最终用户在会话中请求/创建了太多视图,并且正在提交到旧视图。每个会话的默认最大浏览次数为 15。换句话说,如果最终用户在同一会话中使用表单在页面上打开 16 个浏览器窗口/选项卡并提交到第一个,则用户可能会收到 ViewExpiredException.

每个会话的最大浏览次数可在 web.xml 中配置,

<context-param>
    <param-name>com.sun.faces.numberOfViewsInSession</param-name>
    <param-value>15</param-value>
</context-param>

另请参阅 Mojarra 常见问题解答


有没有办法引入额外的日志记录来找出在每种情况下触发此异常的具体情况?

不是通过 JSF 和/或 ViewExpiredException。整个异常仅意味着视图不再存在于会话中。这确实可能有更多根本原因。使用 HttpSessionListener 记录会话创建和销毁 并通过 HttpSessionAttributeListener 可能会有所帮助。


更新 根据评论,在包含表单的缓存页面上按浏览器后退按钮,然后提交表单,当视图过期时,确实也会导致 ViewExpiredException 。这可以通过以下两种方式解决,最好结合使用它们:

  • 指示浏览器缓存页面。
  • 不要不要使用 POST 表单进行简单的页面到页面导航。

有关更多详细信息,请参阅此答案

Other than session expiration, what other conditions might cause ViewExpiredException?

The enduser has requested/created too much views within a session and is submitting to an old view. The default max views per session is 15. In other words, if the enduser opens 16 browser windows/tabs on a page with a form within the same session and submits to the first one, then the user can get ViewExpiredException.

The max views per session is configureable in web.xml by

<context-param>
    <param-name>com.sun.faces.numberOfViewsInSession</param-name>
    <param-value>15</param-value>
</context-param>

See also Mojarra FAQ for other parameters.


Is there a way to introduce additional logging to find out the very specific situation that is triggering this exception in each case?

Not through JSF and/or a ViewExpiredException. The whole exception just means that the view is not present in the session anymore. This can in turn indeed have more underlying causes. Logging the session creation and destroy using a HttpSessionListener and logging the session attribute modifications by HttpSessionAttributeListener may be helpful.


Update as per the comments, pressing the browser back button on a cached page containing a form and then submitting the form thereafter could indeed also cause ViewExpiredException when the view is been expired. This can be solved in following two ways, preferably in a combination of them:

  • Instruct the browser to not cache the pages.
  • Do not use POST forms for plain page-to-page navigation.

For more detail, see this answer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文