ViewExpiredException after upgrade to jsf2

眉间皱痕 提交于 2019-12-06 02:23:32

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/5621674/viewexpiredexception-after-upgrade-to-jsf2

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