title: JSF index out of bounds exception when submiting a form
body: <p>When I click submit button in a JSF form the following exception occurs. It says an Indexout of bounds exception, but I did not use any ArrayList associated with the code. Is this a bug? what should i do to get rid of this error..</p>
  
  <p>Mojarra: 2.0.2 FCS with primefaces 2.2</p>
  
  <p>JSF: 2.0</p>
  
  <p>NetBeans IDE 6.8</p>
  
  <p>Glassfish Domain V3</p>
  
  <p>Form Code:</p>
  
  <pre><code>&lt;p:panel id="jobres" style="min-width: 200px" header="Reservation" widgetVar="jres" closable="true" toggleable="true" &gt;
                              &lt;h:form id="arj" prependId="false" style="width:550px;max-height:400px;overflow:auto;"&gt;
                                  &lt;p:tooltip global="true"/&gt;
                                  &lt;h:panelGrid columns="2" &gt;
                                      &lt;p:panel style="min-width: 220px"&gt;
                                          &lt;h:outputLabel value="1.Job type:"/&gt;
                                      &lt;/p:panel&gt;
                                      &lt;h:panelGroup&gt;
                                          &lt;h:messages id="aerr"/&gt;
                                          &lt;h:selectOneMenu  title="Choose a Jobtype"  value="#{arjob.jobtype}"&gt;
                                              &lt;f:selectItem itemLabel="Sequential" itemValue="sequential"/&gt;
                                              &lt;f:selectItem itemLabel="Parallel" itemValue="parallel"/&gt;
                                          &lt;/h:selectOneMenu&gt;
                                      &lt;/h:panelGroup&gt;
                                      &lt;p:panel&gt;
                                          &lt;h:outputLabel value="2.Executable: *"/&gt;
                                      &lt;/p:panel&gt;
                                      &lt;h:panelGroup&gt;
                                          &lt;p:fileUpload id="aexeupload" fileUploadListener="#{arjob.chooseListener}" auto="true" update="adlist :erdialog" description="Resource Files"&gt;
                                          &lt;/p:fileUpload&gt;
                                          &lt;br/&gt;
                                          &lt;h:panelGroup  id="aexelistwrapper"&gt;
                                              &lt;p:dataList var="fileList"  type="ordered"  id="adlist"  value="#{arjob.fexelist}"&gt;
                                                  &lt;p:column&gt;
                                                      #{fileList}&amp;nbsp;
                                                      &lt;p:commandLink ajax="true"  update="aexelistwrapper" actionListener="#{arjob.removeExe(fileList)}"&gt;
                                                          &lt;p:graphicImage value="images/closebar.png"/&gt;
                                                      &lt;/p:commandLink&gt;
                                                  &lt;/p:column&gt;
                                              &lt;/p:dataList&gt;
                                          &lt;/h:panelGroup&gt;
                                      &lt;/h:panelGroup&gt;
                                      &lt;p:panel&gt;
                                          &lt;h:outputLabel value="3.Argument(s):"/&gt;
                                      &lt;/p:panel&gt;
                                      &lt;h:panelGroup&gt;
                                          &lt;u style="color:orange"&gt;
                                              &lt;i&gt;
                                                  &lt;p:inplace   emptyLabel="Add Arguments"  onEditUpdate="aarglist"&gt;
                                                      &lt;h:inputText title="Enter the arguments" id="aiparg" value="#{arjob.args}"&gt;
                                                          &lt;f:ajax event="valueChange"/&gt;
                                                      &lt;/h:inputText&gt;
                                                      &lt;p:commandButton update="aarglistwrapper erdialog" value="add"  actionListener="#{arjob.addArg}"/&gt;
                                                  &lt;/p:inplace&gt;
                                              &lt;/i&gt;
                                          &lt;/u&gt;
                                      &lt;/h:panelGroup&gt;
                                      &lt;h:panelGroup&gt;
                                      &lt;/h:panelGroup&gt;
                                      &lt;h:panelGroup&gt;
                                          &lt;h:panelGrid id="aarglistwrapper"&gt;
                                              &lt;p:dataList id="aarglist" type="ordered" var="args" value="#{arjob.arglist}"&gt;
                                                  &lt;p:column id="col2"&gt;
                                                      #{args}&amp;nbsp;
                                                      &lt;p:commandLink ajax="true" update="arj:arglistwrapper" actionListener="#{arjob.removeArgs(args)}"&gt;
                                                          &lt;p:graphicImage title="remove" value="images/closebar.png"/&gt;
                                                      &lt;/p:commandLink&gt;
                                                  &lt;/p:column&gt;
                                              &lt;/p:dataList&gt;
                                          &lt;/h:panelGrid&gt;
                                      &lt;/h:panelGroup&gt;
                                      &lt;p:panel&gt;
                                          &lt;h:outputLabel value="4.InputFile(s): *"/&gt;
                                      &lt;/p:panel&gt;
                                      &lt;h:panelGroup&gt;
                                          &lt;p:fileUpload id="ainpupload" fileUploadListener="#{arjob.inputChooseListener}" auto="true" update="aipfilelistwrapper :erdialog" description="Resource Files"&gt;
                                          &lt;/p:fileUpload&gt;
                                          &lt;br/&gt;
                                          &lt;h:panelGroup  id="aipfilelistwrapper"&gt;
                                              &lt;p:dataList var="ipfile"  type="ordered"   id="aipflist"  value="#{arjob.finlist}"&gt;
                                                  &lt;p:column&gt;
                                                      #{ipfile}&amp;nbsp;
                                                      &lt;p:commandLink ajax="true"  update="aipfilelistwrapper" actionListener="#{arjob.removeInfile(ipfile)}"&gt;
                                                          &lt;p:graphicImage value="images/closebar.png"/&gt;
                                                      &lt;/p:commandLink&gt;
                                                  &lt;/p:column&gt;
                                              &lt;/p:dataList&gt;
                                          &lt;/h:panelGroup&gt;
                                      &lt;/h:panelGroup&gt;
                                      &lt;h:panelGroup&gt;
                                          &lt;p:panel &gt;
                                              5)Output File(s):
                                          &lt;/p:panel&gt;
                                      &lt;/h:panelGroup&gt;
                                      &lt;h:panelGroup&gt;
                                          &lt;u style="color:orange"&gt;
                                              &lt;i&gt;
                                                  &lt;p:inplace   emptyLabel="Add file name" id="aipexe"&gt;
                                                      &lt;h:inputText title="Enter the output filenames" id="aexe" value="#{arjob.ofilename}"&gt;
                                                          &lt;f:ajax event="valueChange"/&gt;
                                                      &lt;/h:inputText&gt;
                                                      &lt;p:commandButton update="adoutlist :erdialog" value="add"  actionListener="#{arjob.addOutfile}"/&gt;
                                                  &lt;/p:inplace&gt;
                                              &lt;/i&gt;
                                          &lt;/u&gt;
                                      &lt;/h:panelGroup&gt;
                                      &lt;h:panelGroup&gt;
                                      &lt;/h:panelGroup&gt;
                                      &lt;h:panelGroup&gt;
                                          &lt;h:panelGrid id="afilelistwrapper"&gt;
                                              &lt;p:dataList id="adoutlist" type="ordered" var="ofile" value="#{arjob.foutlist}"&gt;
                                                  &lt;p:column id="acol"&gt;
                                                      #{ofile}&amp;nbsp;
                                                      &lt;p:commandLink ajax="true" update="afilelistwrapper" actionListener="#{arjob.removeOutfile(ofile)}"&gt;
                                                          &lt;p:graphicImage value="images/closebar.png"/&gt;
                                                      &lt;/p:commandLink&gt;
                                                  &lt;/p:column&gt;
                                              &lt;/p:dataList&gt;
                                          &lt;/h:panelGrid&gt;
                                      &lt;/h:panelGroup&gt;
                                      &lt;p:panel&gt;
                                          &lt;h:outputLabel value="6) Operating System"/&gt;
                                      &lt;/p:panel&gt;
                                      &lt;h:panelGroup&gt;
                                          &lt;h:selectOneMenu  title="Select an OperatingSystem"  value="#{arjob.os}"&gt;
                                              &lt;f:selectItem itemLabel="CentOS Release 5.2" itemValue="Cent OS 5.2"/&gt;
                                              &lt;f:selectItem itemLabel="RHEL Server Release 5" itemValue="RHEL server 5"/&gt;
                                              &lt;f:selectItem itemLabel="RHEL Server Release 5.2" itemValue="RHEL server 5.2"/&gt;
                                          &lt;/h:selectOneMenu&gt;
                                      &lt;/h:panelGroup&gt;
                                      &lt;h:panelGroup&gt;
                                          &lt;p:panel&gt;
                                              &lt;h:outputLabel value="7) Physical Memory:"/&gt;
                                          &lt;/p:panel&gt;
                                      &lt;/h:panelGroup&gt;
                                      &lt;h:panelGroup&gt;
                                          &lt;p:spinner min="0" style="width: 100px" stepFactor="10" value="#{arjob.mem}"&gt;
                                          &lt;/p:spinner&gt;(MB)
                                      &lt;/h:panelGroup&gt;
                                      &lt;h:panelGroup&gt;
                                          &lt;p:panel&gt;
                                              &lt;h:outputLabel value="8) Disk Space:"/&gt;
                                          &lt;/p:panel&gt;
                                      &lt;/h:panelGroup&gt;
                                      &lt;h:panelGroup&gt;
                                          &lt;p:spinner min="0" style="width: 100px" stepFactor="10" value="#{arjob.diskspace}"&gt;
                                          &lt;/p:spinner&gt;(MB)
                                      &lt;/h:panelGroup&gt;
                                      &lt;h:panelGroup&gt;
                                          &lt;p:panel&gt;
                                              &lt;h:outputLabel value="9) CPU Mhz:"/&gt;
                                          &lt;/p:panel&gt;
                                      &lt;/h:panelGroup&gt;
                                      &lt;h:panelGroup&gt;
                                          &lt;p:spinner min="0" style="width: 100px" stepFactor="10" value="#{arjob.cpumhz}"&gt;
                                          &lt;/p:spinner&gt;(Mhz)
                                      &lt;/h:panelGroup&gt;
  
                                      &lt;p:panel&gt;
                                          &lt;h:outputLabel value="10) Start Time:"/&gt;
                                      &lt;/p:panel&gt;
  
                                      &lt;h:panelGroup&gt;
                                          &lt;p:inputMask title="(YYYY-MM-DD HH:MM:SS)"  mask="9999-99-99 99:99:99"  value="#{arjob.startt}"&gt;
                                          &lt;/p:inputMask&gt;
                                      &lt;/h:panelGroup&gt;
  
                                      &lt;p:panel&gt;
                                          &lt;h:outputLabel value="11) End Time:"/&gt;
                                      &lt;/p:panel&gt;
  
                                      &lt;h:panelGroup&gt;
                                          &lt;p:inputMask title="(YYYY-MM-DD HH:MM:SS)"  mask="9999-99-99 99:99:99"  value="#{arjob.endt}"&gt;
                                              &lt;p:ajax event="valueChange"/&gt;
                                          &lt;/p:inputMask&gt;
                                      &lt;/h:panelGroup&gt;
                                      &lt;p:panel&gt;
                                          &lt;h:outputLabel value="12) LRMS type"/&gt;
                                      &lt;/p:panel&gt;
                                      &lt;h:panelGroup&gt;
                                          &lt;h:selectOneMenu value="#{arjob.lrms}"&gt;
                                              &lt;f:selectItem itemLabel="PBS" itemValue="PBS"/&gt;
                                              &lt;f:selectItem itemLabel="SGE" itemValue="SGE"/&gt;
                                          &lt;/h:selectOneMenu&gt;
                                      &lt;/h:panelGroup&gt;
                                      &lt;h:panelGroup&gt;
                                          &lt;p:panel&gt;
                                              &lt;h:outputLabel value="13)Number of Nodes: *"/&gt;
                                          &lt;/p:panel&gt;
                                      &lt;/h:panelGroup&gt;
                                      &lt;h:panelGroup&gt;
                                          &lt;h:panelGroup&gt;
                                              &lt;p:spinner style="width: 100px" min="1" max="100" value="#{arjob.numnodes}"&gt;
                                              &lt;/p:spinner&gt;
                                          &lt;/h:panelGroup&gt;
                                      &lt;/h:panelGroup&gt;
                                      &lt;h:panelGroup&gt;
                                      &lt;/h:panelGroup&gt;
                                      &lt;h:panelGroup&gt;
                                          &lt;p:commandButton ajax="false" value="Submit" action="#{arjob.jobSubmitAction}"/&gt;
                                      &lt;/h:panelGroup&gt;
                                  &lt;/h:panelGrid&gt;
                              &lt;/h:form&gt;
                              &lt;p:draggable for="jobres" handle=".ui-panel-titlebar"/&gt;
                          &lt;/p:panel&gt;
  </code></pre>
  
  <p>Exception:</p>
  
  <pre><code>SEVERE: javax.faces.FacesException: Unexpected error restoring state for component with id j_idt7.  Cause: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0.
      at com.sun.faces.application.view.StateManagementStrategyImpl$2.visit(StateManagementStrategyImpl.java:239)
      at com.sun.faces.component.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java:147)
      at javax.faces.component.UIComponent.visitTree(UIComponent.java:1446)
      at javax.faces.component.UIComponent.visitTree(UIComponent.java:1457)
      at javax.faces.component.UIComponent.visitTree(UIComponent.java:1457)
      at javax.faces.component.UIComponent.visitTree(UIComponent.java:1457)
      at com.sun.faces.application.view.StateManagementStrategyImpl.restoreView(StateManagementStrategyImpl.java:223)
      at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:177)
      at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:131)
      at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:430)
      at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:143)
      at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:288)
      at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:199)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:110)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
      at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
      at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
      at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
      at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
      at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
      at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
      at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
      at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
      at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
      at java.lang.Thread.run(Thread.java:619)
  Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
      at java.util.ArrayList.RangeCheck(ArrayList.java:547)
      at java.util.ArrayList.get(ArrayList.java:322)
      at javax.faces.component.AttachedObjectListHolder.restoreState(AttachedObjectListHolder.java:161)
      at javax.faces.component.UIComponentBase.restoreState(UIComponentBase.java:1427)
      at com.sun.faces.application.view.StateManagementStrategyImpl$2.visit(StateManagementStrategyImpl.java:231)
      ... 45 more
  </code></pre>