An exception type that is commonly thrown by the JavaServer Faces (JSF) framework
This exception will be thrown whenever the enduser fires a POST request on a view which does not exist anymore in the server side, because the session has been expired. The view states are by default stored in the session, so they are lost whenever the session expires. A POST request will be fired when the enduser clicks a command button or command link or fires a JSF ajax request.
This can happen when you keep a page open in browser and untouch it for too long so that the session expires (usually, that is 30 minutes, depending on server configuration). Firing a POST request on such a view after session expiration will then result in ViewExpiredException
. This can also happen when the browser loads the page from its cache instead of from the server.
They can be handled by <error-page>
in web.xml
or a custom ExceptionHandler
. They can if necessary be avoided by setting the context parameter javax.faces.STATE_SAVING_METHOD
to client
instead of (default) server
which would then save the serialized view state as a hidden input field value of the POST form. With server side state saving, the browser also needs to be instructed to not cache the dynamic JSF pages.