Questions tagged [viewexpiredexception]

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.

Frequently asked questions:

115 questions
184
votes
11 answers

javax.faces.application.ViewExpiredException: View could not be restored

I have written simple application with container-managed security. The problem is when I log in and open another page on which I logout, then I come back to first page and I click on any link etc or refresh page I get this exception. I guess it's…
l245c4l
  • 4,135
  • 9
  • 35
  • 40
48
votes
1 answer

How to handle session expiration and ViewExpiredException in JSF 2?

Consider the following scenario. I am clicking the submit button of a JSF form, after the session has timed out(expired). The browser displays some exception message: ViewExpiredException: view context could not be restored What I want to do is,…
Selvin
  • 12,333
  • 17
  • 59
  • 80
46
votes
6 answers

Session timeout and ViewExpiredException handling on JSF/PrimeFaces ajax request

I find this article to be useful for non-ajax request How to handle session expiration and ViewExpiredException in JSF 2? but I can't make use of this when I am submitting using an AJAX call. Suppose in a primefaces dialog, I am making a post…
Mark Estrada
  • 9,013
  • 37
  • 119
  • 186
37
votes
2 answers

com.sun.faces.numberOfViewsInSession vs com.sun.faces.numberOfLogicalViews

Mojarra Implementation of JSF 2 has the following context params: com.sun.faces.numberOfViewsInSession (default is 15) com.sun.faces.numberOfLogicalViews (default is 15) What is the difference between them? The documentation doesn't speak much…
Miguel Ping
  • 18,082
  • 23
  • 88
  • 136
18
votes
2 answers

ViewExpiredException shown in java.lang.Throwable error-page in web.xml

I'm working on a JSF web application in which I need to bring up a "Session Expired" page if the view expires, but a general technical error page for all others. The application only goes to the technical error page when I trigger the exception. …
Luke
  • 181
  • 1
  • 1
  • 3
18
votes
5 answers

Handling 'session expired' in JSF web application, running in JBoss AS 5

This question is related to my other question "How to redirect to Login page when Session is expired in Java web application?". Below is what I'm trying to do: I've a JSF web application running on JBoss AS 5 When the user is inactive for, say 15…
Veera
  • 32,532
  • 36
  • 98
  • 137
9
votes
2 answers

Getting ViewExpiredException in clustered environment while state saving method is set to client and user session is valid

I have a JSF application that uses Mojarra 2.2.9 and is deployed on WebSphere 8.5.5.4 on clustered environement and javax.faces.STATE_SAVING_METHOD is set to client. Even though all my application beans are request scoped, sometimes when the user…
Mahmoud Saleh
  • 33,303
  • 119
  • 337
  • 498
9
votes
1 answer

viewExpiredException JSF

To handle viewExpiredException in JSF, I coded javax.faces.application.ViewExpiredException /error.html
user234194
  • 1,683
  • 10
  • 38
  • 56
9
votes
1 answer

com.sun.faces.enableRestoreView11Compatibility what use instead in JSF 1.2

When I have javax.faces.application.ViewExpiredException I want to send user to login page. web.xml ... com.sun.faces.enableRestoreView11Compatibility true
user124722
8
votes
2 answers

Check if session exists JSF

I have a login page where I have a User bean to authenticate username and password for a person. This Bean is Session Scoped. If someone writes a URL and tries to jump the login page, how can I check that and redirect him to the login page? On the…
BRabbit27
  • 6,333
  • 17
  • 90
  • 161
8
votes
2 answers

JSF: Cannot catch ViewExpiredException

I'm developing a JSF 2.0 application on Glassfish v3 and i'm trying to handle the ViewExpiredException. But whatever i do, i always get a Glassfish error report instead of my own error page. To simulate the occurrence of the VEE, i inserted the…
Wolkenarchitekt
  • 20,170
  • 29
  • 111
  • 174
8
votes
2 answers

ViewExpiredException: No saved view state could be found: on submitting a form in JSF

I get the below exception while trying to submit a form. javax.faces.application.ViewExpiredException: /page1.xhtml No saved view state could be found for the view identifier: /page1.xhtml at…
7
votes
2 answers

ViewExpiredException not thrown on ajax request if JSF page is protected by j_security_check

I have a JSF page which is not protected by j_security_check. I perform the following steps: Open the JSF page in a browser. Restart the server. Click a command button on the JSF page to initiate an ajax call. Firebug shows that a…
Ran Tang
  • 241
  • 5
  • 12
6
votes
1 answer

keep getting javax.faces.application.ViewExpiredException: viewId with jsf 2

Whatever I do I get javax.faces.application.ViewExpiredException: viewId. I know how to handle the exception (redirect to the main page again if I get the error), the issue is that any action I call from a commandButton is not executed. Basically I…
user2846482
  • 131
  • 1
  • 3
  • 9
6
votes
5 answers

Handling an expired ViewState in JSF and Richfaces

I have a series signup pages that build on each other. When the users session expires I have a Listener that cleans everything up on the server and that works great. But, if the user attempts to do anything else I just want to redirect them back to…
Kyle Boon
  • 5,213
  • 6
  • 39
  • 50
1
2 3 4 5 6 7 8