1 Reply Latest reply on Apr 5, 2011 1:45 PM by Robert Gary

    MyFaces 2 ViewExpiredException repro case

    Robert Gary Newbie

      I'm able to reproduce the ViewExpiredException exception in MyFaces 2.0.1 (also see in 2.0.4). I'm running JBoss AS 6.0.0.FINAL.

      The problem is that each postback creates a new seralized view in the session. With only 20 (by default) views available other views in the session can have their views expired quickly.

       

      1) Deploy the simple war file included here. Its simply presents a button on the screen that does a post-back

      2) Open a browser with a window to the page (http://localhost:8080/Web for example)

      3) Open another tab in the same browser to the same page (or whatever you need to do in your browser to ensure the two pages share a session)

      4) On the first page, click "Update foo" button 20 times.

      5) Now go to the second page and click "Update foo".

      6) Notice the ViewExpiredException

       

      I don't think each postback should create a new serialized view in the session. This can be verified by looking at

      FacesContext.getCurrentInstance(). getExternalContext().getSessionMap().get("org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementHelper.SERIALIZED_VIEW");

      in your debugger (its too hard to extract this in code).

       

      My code is

       

      @ManagedBean

      @SessionScoped

      public class testBackingBean implements Serializable{

       

          private String msg="foobar";

       

          public String getMsg() {

              return msg;

          }

       

          public void setMsg(String msg) {

              this.msg = msg;

          }

       

       

      }

      xhtml

       

      <?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE html

              PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

              "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <html xmlns="http://www.w3.org/1999/xhtml"

            xmlns:f="http://java.sun.com/jsf/core"

            xmlns:h="http://java.sun.com/jsf/html">

      <head>

          <title>This is a test page</title>

      </head>

      <body>

       

      <h:form>

          <h:outputText value="#{testBackingBean.msg}"/>

       

          <br/>

          <h:commandButton value="Update Foo" />

      </h:form>

      </body>

      </html>