<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: ViewExpiredException</title><link>https://answers.axonivy.com/questions/1035/viewexpiredexception</link><description>&lt;p&gt;My ivy application logs many messages like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;14:02:58.344 ERROR [...Demos.html_dialog] [http-bio-8081-exec-29] [request=/ivy/faces/instances/149AE61A345847D9/EditableTableDemo.xhtml, session=2 (Developer), task=4, application=2147483647, requestId=429, executionContext=SYSTEM, pmv=designer$HtmlDialogDemos$1] 
  Error during rendering of html dialog 'ch.ivyteam.htmldialog.demo.output.EditableTableDemo'
    javax.faces.application.ViewExpiredException: /ch.ivyteam.view.path_info/7/ch.ivyteam.htmldialog.demo.output.EditableTableDemo/EditableTableDemo.xhtmlNo saved view state could be found for the view identifier: /ch.ivyteam.view.path_info/7/ch.ivyteam.htmldialog.demo.output.EditableTableDemo/EditableTableDemo.xhtml
        at org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:181)
        at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:196)
        at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:143)
        at org.apache.myfaces.extensions.validator.core.startup.ExtValLifecycleWrapper.execute(ExtValLifecycleWrapper.java:59)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
[--snip--]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What do these messages mean? Why does such an error occur? How can I prevent them?&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/1035/viewexpiredexception" rel="self"></atom:link><language>en</language><lastBuildDate>Tue, 19 May 2015 15:27:31 -0400</lastBuildDate><item><title>Answer by Andreas</title><link>https://answers.axonivy.com/questions/1035/viewexpiredexception/1321</link><description>&lt;p&gt;As I have seen, while starting up the ivy engine, no CLIENT_VIEW_STATE_TIMEOUT parameter is registered.  &lt;/p&gt;
&lt;p&gt;By setting up the web.xml with parameter:&lt;/p&gt;
&lt;p&gt;&amp;lt;context-param&amp;gt;
   &amp;lt;param-name&amp;gt;org.apache.myfaces.CLIENT_VIEW_STATE_TIMEOUT&amp;lt;/param-name&amp;gt;
   &amp;lt;param-value&amp;gt;0&amp;lt;/param-value&amp;gt;
&amp;lt;/context-param&amp;gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;would that prevent of a ViewExpiredException too?&lt;/li&gt;
&lt;li&gt;why it is not registered?&lt;/li&gt;
&lt;/ul&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Andreas</dc:creator><pubDate>Tue, 19 May 2015 15:27:31 -0400</pubDate><guid>https://answers.axonivy.com/questions/1035/viewexpiredexception/1321</guid></item><item><title>Answer by Dominik Regli</title><link>https://answers.axonivy.com/questions/1035/viewexpiredexception/1036</link><description>&lt;p&gt;MyFaces only keeps a defined number of views (respectively view states) per session. The log entry indicates, that access to an old view state happened but this view was not saved in memory anymore.
This situation may occur, when someone uses a JSF application in multiple browser tabs or when navigating 'back' (on the browser) is used dissipated.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;You can adjust this behavior by configuring MyFaces. To do so, consider following. &lt;/p&gt;
&lt;h2&gt;Number of views in session&lt;/h2&gt;
&lt;p&gt;Per default, MyFaces keeps the past 20 view states per session. Note, that each request causes generation of a new view. As a result, when navigating through JSF pages, it's basically possible, to navigate 'back' for 20 times. Navigating 'back' further, leads you to views, that don't work anymore since no view state is saved for them.
The same happens, when someone is working with with two or more browser tabs/windows. Imagine, someone opens the application first in windowA and then also in a second one (windowB). If now, more than 20 actions are performed (means 20 requests sent) in windowB, it's not possible anymore to perform actions in windowA, since the view state belonging to windowA was already deleted.&lt;/p&gt;
&lt;p&gt;This value can be configured with the context-param &lt;code&gt;org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Number of sequential views in session&lt;/h2&gt;
&lt;p&gt;It does not matter, if an AJaX request or a "normal" http request is sent - each time, a new view is created. But navigating 'back' with the browser, brings you to the past page, before a "normal" request. Any AJaX request is skipped by the browser's back functionality. 
This leads us to the next issue related to the limitation mentioned above: Imagine, someone is on pageA and then performs a "normal" request (e.g. form-submit) which leads him to pageB. Afterwards, on pageB, the user performs 20 actions which all only create AJaX requests. Now, navigating back by browser only one time is already too much. The state of pageA is not available anymore, it will not work properly.&lt;/p&gt;
&lt;p&gt;That's the reason, why there is another context-param &lt;code&gt;org.apache.myfaces.NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION&lt;/code&gt;. By default it's not set. It allows to keep the number of saved views in a sequence (whereas a sequence can be seen as a series of only AJaX requests), smaller than the total number of saved views. Hence, this may be the key to improve the behavior of a JSF application when multiple browser tabs are used or navigating 'back' is used often.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;Note, that a bigger number of saved views causes a bigger memory footprint of a session. This is also the reason why it's limited at all. Configure the params mentioned above relates to the requirements of your application.&lt;/p&gt;
&lt;p&gt;The available context-params of MyFaces are documented on &lt;a href="https://myfaces.apache.org/core22/myfaces-impl/webconfig.html"&gt;https://myfaces.apache.org/core22/myfaces-impl/webconfig.html&lt;/a&gt;
In the ivy Engine, they can be added to the web.xml in the folder "ServerRoot"/webapps/ivy/WEB-INF/ &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dominik Regli</dc:creator><pubDate>Fri, 14 Nov 2014 15:45:57 -0500</pubDate><guid>https://answers.axonivy.com/questions/1035/viewexpiredexception/1036</guid></item></channel></rss>