javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-3241

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

    Details

      Description

      IndexOutOfBoundsException caused by javax.faces.component.AttachedObjectListHolder::restoreState(FacesContext context, Object state)

      1. 20140911-1934Z-i_moj_3241-changebundle.txt
        5 kB
        Ed Burns
      2. changebundle.txt
        13 kB
        ren.zhijun.oracle
      3. changebundle.txt
        31 kB
        ren.zhijun.oracle
      4. JAVASERVERFACES-3241.patch
        1 kB
        Manfred Riem

        Issue Links

          Activity

          Hide
          Andrei Ivanov added a comment -

          I still see this using 2.2.9

           java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
          	at java.util.ArrayList.rangeCheck(ArrayList.java:635)
          	at java.util.ArrayList.get(ArrayList.java:411)
          	at javax.faces.component.AttachedObjectListHolder.restoreState(Unknown Source)
          	at javax.faces.component.UIComponentBase.restoreState(Unknown Source)
          	at com.sun.faces.application.view.FaceletPartialStateManagementStrategy$2.visit(Unknown Source)
          	at com.sun.faces.component.visit.FullVisitContext.invokeVisitCallback(Unknown Source)
          	at javax.faces.component.UIComponent.visitTree(Unknown Source)
          	at javax.faces.component.UIComponent.visitTree(Unknown Source)
          	at javax.faces.component.UIComponent.visitTree(Unknown Source)
          	at javax.faces.component.UIComponent.visitTree(Unknown Source)
          	at com.sun.faces.application.view.FaceletPartialStateManagementStrategy.restoreView(Unknown Source)
          	at com.sun.faces.application.StateManagerImpl.restoreView(Unknown Source)
          	at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(Unknown Source)
          	at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(Unknown Source)
          	at com.sun.faces.application.view.MultiViewHandler.restoreView(Unknown Source)
          	at javax.faces.application.ViewHandlerWrapper.restoreView(Unknown Source)
          	at com.sun.faces.lifecycle.RestoreViewPhase.execute(Unknown Source)
          	at com.sun.faces.lifecycle.Phase.doPhase(Unknown Source)
          	at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(Unknown Source)
          	at com.sun.faces.lifecycle.LifecycleImpl.execute(Unknown Source)
          	at javax.faces.webapp.FacesServlet.service(Unknown Source)
          
          Show
          Andrei Ivanov added a comment - I still see this using 2.2.9 java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:635) at java.util.ArrayList.get(ArrayList.java:411) at javax.faces.component.AttachedObjectListHolder.restoreState(Unknown Source) at javax.faces.component.UIComponentBase.restoreState(Unknown Source) at com.sun.faces.application.view.FaceletPartialStateManagementStrategy$2.visit(Unknown Source) at com.sun.faces.component.visit.FullVisitContext.invokeVisitCallback(Unknown Source) at javax.faces.component.UIComponent.visitTree(Unknown Source) at javax.faces.component.UIComponent.visitTree(Unknown Source) at javax.faces.component.UIComponent.visitTree(Unknown Source) at javax.faces.component.UIComponent.visitTree(Unknown Source) at com.sun.faces.application.view.FaceletPartialStateManagementStrategy.restoreView(Unknown Source) at com.sun.faces.application.StateManagerImpl.restoreView(Unknown Source) at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(Unknown Source) at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(Unknown Source) at com.sun.faces.application.view.MultiViewHandler.restoreView(Unknown Source) at javax.faces.application.ViewHandlerWrapper.restoreView(Unknown Source) at com.sun.faces.lifecycle.RestoreViewPhase.execute(Unknown Source) at com.sun.faces.lifecycle.Phase.doPhase(Unknown Source) at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(Unknown Source) at com.sun.faces.lifecycle.LifecycleImpl.execute(Unknown Source) at javax.faces.webapp.FacesServlet.service(Unknown Source)
          Hide
          Andrei Ivanov added a comment -

          And on 2.2.10 (with line numbers now)

          java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
                 at java.util.ArrayList.rangeCheck(ArrayList.java:635)
                 at java.util.ArrayList.get(ArrayList.java:411)
                 at javax.faces.component.AttachedObjectListHolder.restoreState(AttachedObjectListHolder.java:166)
                 at javax.faces.component.UIComponentBase.restoreState(UIComponentBase.java:1611)
                 at com.sun.faces.application.view.FaceletPartialStateManagementStrategy$2.visit(FaceletPartialStateManagementStrategy.java:379)
                 at com.sun.faces.component.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java:151)
                 at javax.faces.component.UIComponent.visitTree(UIComponent.java:1689)
                 at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
                 at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
                 at com.sun.faces.application.view.FaceletPartialStateManagementStrategy.restoreView(FaceletPartialStateManagementStrategy.java:366)
                 at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:138)
                 at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123)
                 at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:586)
                 at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:150)
                 at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:353)
                 at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:197)
                 at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
                 at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:121)
                 at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
                 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
          

          Can we reopen this or should I create a new ticket?

          Show
          Andrei Ivanov added a comment - And on 2.2.10 (with line numbers now) java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:635) at java.util.ArrayList.get(ArrayList.java:411) at javax.faces.component.AttachedObjectListHolder.restoreState(AttachedObjectListHolder.java:166) at javax.faces.component.UIComponentBase.restoreState(UIComponentBase.java:1611) at com.sun.faces.application.view.FaceletPartialStateManagementStrategy$2.visit(FaceletPartialStateManagementStrategy.java:379) at com.sun.faces.component.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java:151) at javax.faces.component.UIComponent.visitTree(UIComponent.java:1689) at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700) at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700) at com.sun.faces.application.view.FaceletPartialStateManagementStrategy.restoreView(FaceletPartialStateManagementStrategy.java:366) at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:138) at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123) at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:586) at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:150) at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:353) at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:197) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:121) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646) Can we reopen this or should I create a new ticket?
          Hide
          ren.zhijun.oracle added a comment -

          Hi Andrei,

          Can you attach your application here to reproduce the issue?

          In my commitment in -r13723, there was an test case which verify the issue has been fixed. so I need you to provide a reproducer to do the investigation.

          BR,
          Zhijun

          Show
          ren.zhijun.oracle added a comment - Hi Andrei, Can you attach your application here to reproduce the issue? In my commitment in -r13723, there was an test case which verify the issue has been fixed. so I need you to provide a reproducer to do the investigation. BR, Zhijun
          Hide
          Andrei Ivanov added a comment -

          Hm,
          After 2 long days of trying to create an app to reproduce the issue, I've reached the conclusion that it was caused by my attempt to improve the handling of "redirect to the initial URL after form login" for AJAX requests.

          This is what I think was happening:

          • load a page with an ajax poll component to refresh some sections of the page
          • on a separate window/tab, logout of the app to destroy the session
          • the poll component makes an ajax call which gets redirected to the login page (also JSF), the JSF servlet creates the state and returns the IDs in a partial update XML
          • in that 2nd tab, login back in the app
          • in the 1st tab, the poll components continues making calls which now try to restore the state obtained from the login form view

          After removing my dirty hack (and replacing it with the correct fix inspired from this post, which was clearing the JSF headers and parameters that marking the request as a partial update ajax call, I now get a proper ViewExpiredException.

          Sorry for the noise

          Show
          Andrei Ivanov added a comment - Hm, After 2 long days of trying to create an app to reproduce the issue, I've reached the conclusion that it was caused by my attempt to improve the handling of "redirect to the initial URL after form login" for AJAX requests. This is what I think was happening: load a page with an ajax poll component to refresh some sections of the page on a separate window/tab, logout of the app to destroy the session the poll component makes an ajax call which gets redirected to the login page (also JSF), the JSF servlet creates the state and returns the IDs in a partial update XML in that 2nd tab, login back in the app in the 1st tab, the poll components continues making calls which now try to restore the state obtained from the login form view After removing my dirty hack (and replacing it with the correct fix inspired from this post , which was clearing the JSF headers and parameters that marking the request as a partial update ajax call, I now get a proper ViewExpiredException . Sorry for the noise
          Hide
          michaelbreu added a comment -

          Sorry to comment on a closed issue, however I'm able to reproduce this problem with 2.2.13 .

          I just debugged through the relevant statements

          Bar.java
                      for (int i = 0, len = attachedObjects.length; i < len; i++) {
                          T l = this.attachedObjects.get(i);
                          if (l instanceof StateHolder) {
                              ((StateHolder) l).restoreState(context, attachedObjects[i]);
                          }
                      }
          

          There seems to be a "code smell": attachedObjects and this.attachedObjects are two different objects.

          Could someone have a look on it?

          Show
          michaelbreu added a comment - Sorry to comment on a closed issue, however I'm able to reproduce this problem with 2.2.13 . I just debugged through the relevant statements Bar.java for ( int i = 0, len = attachedObjects.length; i < len; i++) { T l = this .attachedObjects.get(i); if (l instanceof StateHolder) { ((StateHolder) l).restoreState(context, attachedObjects[i]); } } There seems to be a "code smell": attachedObjects and this.attachedObjects are two different objects. Could someone have a look on it?

            People

            • Assignee:
              ren.zhijun.oracle
              Reporter:
              thomas.meister
            • Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: