0 Replies Latest reply on Jun 19, 2009 1:13 AM by Rajneesh Kumar

    ViewExpiredException: Possible solution approach discussion.

    Rajneesh Kumar Newbie

      I have posted the same question in the RichFaces User forum also, posting here just to confirm might be it is a design issue.

      We recently upgraded Rich Faces to 3.3.0 along with my faces 1.2.6.

      We were facing a problem that if we access the application first time, first page gets render properly but further it does not work. But we simply relogin into application again there after same set of pages work fine.

      Please see what we found in this.

      Initial configurations were as follows..
      org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION = 4

      Always, if we use new browser / (Clean browser cache) and login into application first page is rendered properly. But, if we click any of the link on this page then ViewExpiredException is thrown because in the post back request required view id is not available in the server cached views list.

      I debug the code and found couple of facts,

      1) AjaxStateHolder class uses ContextInitParameters class to rely on the no. of views to store in a session and expects a new context param ' com.sun.faces.numberOfViewsInSession ' to be declare in the web.xml.

      Now, we can explains what happens is while doing login browser sends up lots of request to server for page as well as for every image which is being displayed, or style sheets or js files etc.

      And, sever stores up each request generated view in the same 'views' list which it is holding for pages. So, images etc are replacing the page view in the list for the first time as there were around total 25 requests are generating in our case for the cleaned browser.

      After this, we do login second time and browser does not send separate requests for images and css as those are cached at browser end, so pages works fine because only one view (actual view for the page) get stored and it is available when it is required in immediate post back request.

      Proposed Solution 1:

      I am not sure, why AjaxStateHolder is storing every resource generated view in the same views list. Request, which are made for images, css and scripts should not be stored in the views state map.

      Is this correct to store images, css and scripts in the same view state map or can I put a check on this chunk of code not to put images, css and scripts in the AjaxStateHolder view state map ? .

      If it is really not required to store images, css and scripts in the same view state map, this will solve our problem completely.

      Well, I didn't check the old version code for myfaces how it was handling this, whether it was storing the images and css etc in the same view state map or not but we never faced this problem in older version of my faces and rich faces.

      Proposed Solution 2 [Temporarily]:
      I can set up com.sun.faces.numberOfViewsInSession variable to a high no. i.e. 25 which is the exact in our case and it will work fine. But, if I increase any image on the same first page. This problem could again in front of us.