0

I have a large richfaces tree and each element in the tree can be selected which loads the content via AJAX and edited which redirects you to a new page. This was working great until I had a particularly large document I was working on and saving no longer worked. You got redirected to the edit page which showed the right content, but trying to "save" any edits resulted in a ViewExpiredException.

I tried tweaking a lot of parameters and eventually arrived at two parameters that fixed it:

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

As far as I can see, the default for each is 15, I set them to a ridiculous 500 and the application works again. Unfortunately because I don't know where the problem is situated and it's a large application I can't show you any relevant code.

But the questions are: what exactly do these parameters do, what could cause me to bump into these exceptions and what are acceptable values?

UPDATE

I'm not entirely sure why the question got downvoted but if it is with regards to the supposed duplicate: I had found that post through google but the link it provides is dead. Except for the bog standard (and vague) definition of the parameters, there does not seem to be much information on them.

nablex
  • 4,635
  • 4
  • 36
  • 51
  • Duplicate of [this](http://stackoverflow.com/questions/4105439/jsf-numberofviewsinsession-vs-numberoflogicalviews-and-viewexpiredexception). Please google a bit before you ask a question. – Adel Boutros Feb 22 '13 at 13:34
  • Please note that I had found that page but the only link it contains is dead. – nablex Feb 22 '13 at 13:38

1 Answers1

1

When server side state saving is used (which is default) than those two parameters can be used to configure maximum number of logical and actual views.

Logical view is top level view which is created on every GET request (for example when you open page in new browser window or tab, entering address in address bar of browser, iframes...). Each logical view can have some number of associated actual views. Actual views are created as user navigate through your pages with standard JSF mechanisms (for example if you navigate to page returned from action methods in commandButton). Both queues of views use LRU algorithm to decide when view will be removed, and maximum number of those queues are limited by values of these two parameters.

So, com.sun.faces.numberOfViewsInSession defines the maximum number of JSF views stored in the session for per logical view, and com.sun.faces.numberOfLogicalViews defines the maximum number of logical views to store per session.

According to information you provided a suspect that configuration of com.sun.faces.numberOfViewsInSession solved your problem, but you must further investigate why is created so many views.

Additional link:

partlov
  • 13,789
  • 6
  • 63
  • 82
  • Very informative, thank you. Is there any consideration of "size" for the actual views? Because as far as I can tell the (GET/POST) actions undertaken to edit the large document are exactly the same as for a smaller document, the only difference is the size of said document. – nablex Feb 22 '13 at 14:36
  • Well, for further analyze I must see more of your page and logic. One more idea, each jsf `h:form` is considered separate view (in terms of view state savings on server), so technically if you have 15 forms, one more updated form will fire `ViewExpiredException` – partlov Feb 22 '13 at 14:53
  • Due to several reasons lost to history, the entire application is in a single form at the root. This means index.xhtml (which hosts the tree) has the root form and when you click you are redirected (via GET) to edit.xhtml which has a root form. There ajax is used to perform postbacks when you save. – nablex Feb 25 '13 at 06:29