1

I've a problem with JSF session handling: At first i got everytime a viewExpiredException:

javax.faces.application.ViewExpiredException: viewId:/anyForm.jsf - View /anyForm.jsf could not be restored.

So I added the following code to my web.xml file:

<error-page>
        <exception-type>javax.faces.application.ViewExpiredException</exception-type>
        <location>/index.jsf?reason=expired</location>
</error-page>

and the following in my index.jsf file (which also got some forms and inputs):

<h:outputText value="#{messages.session_expired}"
              rendered="#{param.reason == 'expired'}" />

whenever I get a timeout now, I am redirected to the index.jsf and the text is shown, but if I enter a value in an input and press the submit button of the form, I still get a redirect to my index.jsf. So, I am stuck in a loop. I also tried things like:

<context-param>
        <param-name>com.sun.faces.enableRestoreView11Compatibility</param-name>
        <param-value>true</param-value>
</context-param>

due to the fact that I read index.jsf then automatically create a new session. However, this didn't help me at all. I also get this exception if I got a (loop) timeout and change a value of a input and submit the form (I am using primefaces "spinner" input):

javax.servlet.ServletException: Index: 1, Size: 1
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)

java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
    java.util.ArrayList.RangeCheck(ArrayList.java:547)
    java.util.ArrayList.get(ArrayList.java:322)
    javax.faces.component.AttachedObjectListHolder.restoreState(AttachedObjectListHolder.java:165)
    javax.faces.component.UIInput.restoreState(UIInput.java:1411)
    com.sun.faces.application.view.StateManagementStrategyImpl$2.visit(StateManagementStrategyImpl.java:276)
    com.sun.faces.component.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java:151)
    javax.faces.component.UIComponent.visitTree(UIComponent.java:1589)
    javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
    javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
    javax.faces.component.UIForm.visitTree(UIForm.java:344)
    javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
    javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
    com.sun.faces.application.view.StateManagementStrategyImpl.restoreView(StateManagementStrategyImpl.java:263)
    com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:188)
    com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123)
    com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:452)
    com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:148)
    com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:192)
    com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
    com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
Emond
  • 50,210
  • 11
  • 84
  • 115
user1879988
  • 175
  • 1
  • 2
  • 5
  • Maybe [this](http://stackoverflow.com/questions/4992526/how-to-handle-session-expiration-in-jsf-2-0) helps. – SJuan76 Dec 21 '12 at 12:17
  • no, this is where i got my "solution" from. sure i could insert an meta-refresh, so i never get a timeout, but that would be a bad solution... – user1879988 Dec 21 '12 at 12:20
  • Have you excluded the browser cache from being the suspect? See also http://stackoverflow.com/a/3642969 and http://stackoverflow.com/a/9931378 – BalusC Dec 21 '12 at 13:53

0 Answers0