title: ICEFaces 3.1: NullPointerException raised while re-rendering a view
body: <p>I'm facing a problem with ICEFaces. It seems like it's unable to properly refresh a view.<br>
  I'll provide you with the view, the flow, the bean and the details of the strange behaviour  I found thanks to some debugging sessions.  </p>
  
  <p>Basically, I'm dealing with a lazy loaded ace:DataTable.</p>
  
  <pre><code>&lt;ace:dataTable id="blocchiTable" [..] /&gt;
  </code></pre>
  
  <p>I select some rows and click on a button labeled with "Modifica" (the Italian for "Edit"):</p>
  
  <pre><code>&lt;ace:menuItem id="modificaBloccoButton" value="Modifica" action="modificaBlocco" icon="ui-icon ui-icon-pencil" /&gt;`
  </code></pre>
  
  <p>As you will see in the flow, the related click event leads the flow to a decision-state:</p>
  
  <pre><code>&lt;view-state id="creablocco" view="creablocco.xhtml"&gt;
      [.. other stuff ..]
      &lt;transition on="modificaBlocco" to="decidiModifica"&gt;
          &lt;evaluate expression="flowScope.blocchiBean.getRigheSelezionate()" result="flowScope.righeSelezionate"/&gt;
      &lt;/transition&gt;
  &lt;/view-state&gt;
  &lt;decision-state id="decidiModifica"&gt;
      &lt;if test="!(flowScope.righeSelezionate).isEmpty()" then="modificaBlocco" else="fine" /&gt;
  &lt;/decision-state&gt;
  </code></pre>
  
  <p>and, afterwards, another view-state, associated to the same view of the initial state. While entering the new view-state, the flow asks the bean to enable the cellEditor for the proper rows, so that, when the view is re-rendered, the selected rows will be editable.</p>
  
  <pre><code>&lt;view-state id="modificaBlocco" view="creablocco.xhtml"&gt;
      &lt;on-entry&gt;
          &lt;evaluate expression="flowScope.blocchiBean.abilitaModifica()"/&gt;
      &lt;/on-entry&gt;    
      &lt;transition on="salvaModificheBlocco" to="fine"&gt;
          &lt;evaluate expression="flowScope.blocchiBean.salvaBlocchi()"/&gt;
      &lt;/transition&gt;
  &lt;/view-state&gt;
  </code></pre>
  
  <p>Unfortunaly, while re-rendering the view (I already checked that the method specified in the <code>&lt;on-entry&gt;</code> section is actually invoked), the following <strong>exception</strong> is raised:</p>
  
  <pre><code>AVVERTENZA: queued exception
  java.lang.NullPointerException
      at org.icefaces.impl.util.DOMUtils.isWhitespaceText(DOMUtils.java:394)
      at org.icefaces.impl.util.DOMUtils.printNode(DOMUtils.java:351)
      at org.icefaces.impl.util.DOMUtils.printNode(DOMUtils.java:355)
      at org.icefaces.impl.util.DOMUtils.printNode(DOMUtils.java:355)
      at org.icefaces.impl.util.DOMUtils.printNode(DOMUtils.java:355)
      at org.icefaces.impl.util.DOMUtils.printNode(DOMUtils.java:306)
      at org.icefaces.impl.util.DOMUtils.printNode(DOMUtils.java:290)
      at org.icefaces.impl.context.DOMResponseWriter.endDocument(DOMResponseWriter.java:225)
      at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:410)
      at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
      at org.springframework.faces.webflow.FlowViewHandler.renderView(FlowViewHandler.java:99)
      at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
      at org.springframework.faces.webflow.FlowLifecycle.render(FlowLifecycle.java:80)
      at org.springframework.faces.webflow.JsfView.render(JsfView.java:89)
      at org.springframework.webflow.engine.ViewState.render(ViewState.java:296)
      at org.springframework.webflow.engine.ViewState.refresh(ViewState.java:243)
      at org.springframework.webflow.engine.ViewState.resume(ViewState.java:221)
      at org.springframework.webflow.engine.Flow.resume(Flow.java:545)
      at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:258)
      at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
      at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
      at org.springframework.faces.webflow.JsfFlowHandlerAdapter.handle(JsfFlowHandlerAdapter.java:48)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
      at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
      at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:101)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:182)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173)
      at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
      at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at com.springsource.insight.collection.tcserver.request.HttpRequestOperationCollectionValve.traceNextValve(HttpRequestOperationCollectionValve.java:112)
      at com.springsource.insight.collection.tcserver.request.HttpRequestOperationCollectionValve.invoke(HttpRequestOperationCollectionValve.java:94)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:662)
  </code></pre>
  
  <p>This is the <strong>complete view</strong>:  </p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
  &lt;ui:composition xmlns="http://www.w3.org/1999/xhtml"
                  xmlns:ui="http://java.sun.com/jsf/facelets"
                  xmlns:ace="http://www.icefaces.org/icefaces/components" 
                  xmlns:ice="http://www.icesoft.com/icefaces/component"
                  xmlns:h="http://java.sun.com/jsf/html"
                  xmlns:f="http://java.sun.com/jsf/core"
                  template="/resources/includes/templates/template.xhtml"&gt;
      &lt;ui:param name="pageTitle" value="Crea blocco" /&gt;
      &lt;ui:define name="page-content"&gt;
          &lt;ace:panel id="personalInfoInputPanel" header="Crea blocco"&gt;
              &lt;div class="div_creablocco"&gt;
                  &lt;h:form id="creabloccoform"&gt;
                      &lt;h:panelGrid id="creabloccoInputGrid" columns="1" styleClass="table_creablocco"&gt;
                          &lt;ace:textEntry id="numeroFile" value="#{creaBloccoBean.numeroFile}" label="Numero file:" labelPosition="left" required="true" requiredIndicator="(*)" indicatorPosition="right"&gt;
                          &lt;/ace:textEntry&gt;
                          &lt;ace:textEntry id="numeroColonne" value="#{creaBloccoBean.numeroColonne}" label="Numero colonne:" labelPosition="left" required="true" requiredIndicator="(*)" indicatorPosition="right"&gt;
                          &lt;/ace:textEntry&gt;
                          &lt;ace:textEntry id="posizioneX" value="#{creaBloccoBean.posizioneX}" label="Coordinata X:" labelPosition="left" required="true" requiredIndicator="(*)" indicatorPosition="right"&gt;
                          &lt;/ace:textEntry&gt;
                          &lt;ace:textEntry id="posizioneY" value="#{creaBloccoBean.posizioneY}" label="Coordinata Y:" labelPosition="left" required="true" requiredIndicator="(*)" indicatorPosition="right"&gt;
                          &lt;/ace:textEntry&gt;
                          &lt;ace:pushButton id="pushBttnCreaBlocco"  value="Crea blocco" action="creaBlocco"/&gt;
                      &lt;/h:panelGrid&gt;
                  &lt;/h:form&gt;
              &lt;/div&gt;
          &lt;/ace:panel&gt;
  
          &lt;ace:panel id="blocchiPanel" header="Blocchi"&gt;
              &lt;h:form id="blocchiTableForm"&gt;
                  &lt;ace:menuBar id="iconeBloccoMenu" rendered="#{!blocchiBean.modificaInCorso}"&gt;
                      &lt;ace:menuItem id="dettagliBloccoButton" value="Dettagli" action="dettagliBlocco" icon="ui-icon ui-icon-search" /&gt;
                      &lt;ace:menuItem id="modificaBloccoButton" value="Modifica" action="modificaBlocco" icon="ui-icon ui-icon-pencil" /&gt;
                      &lt;ace:menuItem id="cancellaBloccoButton" value="Cancella" action="cancellaBlocco" icon="ui-icon ui-icon-closethick" /&gt;
                  &lt;/ace:menuBar&gt;
                  &lt;ace:menuBar id="iconeModificaBloccoMenu" rendered="#{flowScope.blocchiBean.modificaInCorso}"&gt;
                      &lt;ace:menuItem id="annullaModificheButton" value="Annulla" action="annullaModificheBlocco" icon="ui-icon ui-icon-arrow-1-w" /&gt;
                      &lt;ace:menuItem id="salvaModifiche" value="Salva" action="salvaModificheBlocco" icon="ui-icon ui-icon-disk" /&gt;
                  &lt;/ace:menuBar&gt;
                  &lt;ace:dataTable id="blocchiTable" value="#{blocchi}"
                      binding="#{flowScope.blocchiBean.table}" stateMap="#{flowScope.blocchiBean.stateMap}"
                      selectionMode="multiple" doubleClickSelect="false"
                      rowSelectListener="#{flowScope.blocchiBean.selectListener}"
                      rowUnselectListener="#{flowScope.blocchiBean.deselectListener}" var="blocco"
                      lazy="true" rows="10" paginator="true" paginatorPosition="bottom"&gt;
                      &lt;ace:column id="idBloccoColumn" headerText="ID" styleClass="id"&gt;
                          &lt;h:outputText id="idBloccoText" value="#{blocco.id}" /&gt;
                      &lt;/ace:column&gt;
                      &lt;ace:column id="numeroFileBloccoColumn" headerText="Numero file"
                          styleClass="numFile"&gt;
                          &lt;ace:cellEditor&gt;
                              &lt;f:facet name="output"&gt;
                                  &lt;h:outputText id="numeroFileBloccoText"
                                      value="#{blocco.numeroFile}" /&gt;
                              &lt;/f:facet&gt;
                              &lt;f:facet name="input"&gt;
                                  &lt;h:inputText id="numeroFileBloccoInput"
                                      value="#{blocco.numeroFile}" /&gt;
                              &lt;/f:facet&gt;
                          &lt;/ace:cellEditor&gt;
  
                      &lt;/ace:column&gt;
                      &lt;ace:column id="numeroColonneBloccoColumn"
                          headerText="Numero colonne" styleClass="numColonne"&gt;
                          &lt;ace:cellEditor&gt;
                              &lt;f:facet name="output"&gt;
                                  &lt;h:outputText id="numeroColonneBloccoText"
                                      value="#{blocco.numeroColonne}" /&gt;
                              &lt;/f:facet&gt;
                              &lt;f:facet name="input"&gt;
                                  &lt;h:inputText id="numeroColonneBloccoInput"
                                      value="#{blocco.numeroColonne}" /&gt;
                              &lt;/f:facet&gt;
                          &lt;/ace:cellEditor&gt;
  
                      &lt;/ace:column&gt;
                      &lt;ace:column id="posizioneXBloccoColumn" headerText="Posizione X"
                          styleClass="posX"&gt;
                          &lt;ace:cellEditor&gt;
                              &lt;f:facet name="output"&gt;
                                  &lt;h:outputText id="posizioneXBloccoText"
                                      value="#{blocco.posizioneX}" /&gt;
                              &lt;/f:facet&gt;
                              &lt;f:facet name="input"&gt;
                                  &lt;h:inputText id="posizioneXBloccoInput"
                                      value="#{blocco.posizioneX}" /&gt;
                              &lt;/f:facet&gt;
                          &lt;/ace:cellEditor&gt;
  
                      &lt;/ace:column&gt;
                      &lt;ace:column id="posizioneYBloccoColumn" headerText="Posizione Y"
                          styleClass="posY"&gt;
                          &lt;ace:cellEditor&gt;
                              &lt;f:facet name="output"&gt;
                                  &lt;h:outputText id="posizioneYBloccoText"
                                      value="#{blocco.posizioneY}" /&gt;
                              &lt;/f:facet&gt;
                              &lt;f:facet name="input"&gt;
                                  &lt;h:inputText id="posizioneYBloccoInput"
                                      value="#{blocco.posizioneY}" /&gt;
                              &lt;/f:facet&gt;
                          &lt;/ace:cellEditor&gt;
  
                      &lt;/ace:column&gt;
                  &lt;/ace:dataTable&gt;
              &lt;/h:form&gt;
          &lt;/ace:panel&gt;
      &lt;/ui:define&gt;
  &lt;/ui:composition&gt;  
  </code></pre>
  
  <p>This is the <strong>complete flow</strong>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;flow xmlns="http://www.springframework.org/schema/webflow"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.springframework.org/schema/webflow
          http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"&gt;
  
      &lt;var name="creaBloccoBean" class="com.infoone.siglo.viewbeans.CreaBloccoBean" /&gt;
      &lt;var name="blocchiBean" class="com.infoone.siglo.viewbeans.BlocchiBean" /&gt;
  
      &lt;view-state id="creablocco" view="creablocco.xhtml"&gt;
          &lt;on-entry&gt;
              &lt;evaluate expression="flowScope.blocchiBean.getBlocchi()" result="flowScope.blocchi" /&gt;
          &lt;/on-entry&gt;
          &lt;transition on="creaBlocco" to="fine"&gt;
              &lt;evaluate expression="gestoreBlocchiCtr.creaBlocco(creaBloccoBean)" /&gt;
          &lt;/transition&gt;
          &lt;transition on="cancellaBlocco" to="decidiCancellazione"&gt;
              &lt;evaluate expression="flowScope.blocchiBean.getRigheSelezionate()" result="flowScope.righeSelezionate"/&gt;
          &lt;/transition&gt;
          &lt;transition on="modificaBlocco" to="decidiModifica"&gt;
              &lt;evaluate expression="flowScope.blocchiBean.getRigheSelezionate()" result="flowScope.righeSelezionate"/&gt;
          &lt;/transition&gt;
      &lt;/view-state&gt;
  
      &lt;decision-state id="decidiCancellazione"&gt;
          &lt;if test="!(flowScope.righeSelezionate).isEmpty()" then="cancellaBlocco" else="fine" /&gt;
      &lt;/decision-state&gt;
      &lt;decision-state id="decidiModifica"&gt;
          &lt;if test="!(flowScope.righeSelezionate).isEmpty()" then="modificaBlocco" else="fine" /&gt;
      &lt;/decision-state&gt;
  
      &lt;action-state id="cancellaBlocco"&gt;
          &lt;evaluate expression="gestoreBlocchiCtr.rimuoviBlocchi(flowScope.righeSelezionate)" /&gt;
          &lt;transition to="fine"/&gt;
      &lt;/action-state&gt;
      &lt;view-state id="modificaBlocco" view="creablocco.xhtml"&gt;
          &lt;on-entry&gt;
              &lt;evaluate expression="flowScope.blocchiBean.abilitaModifica()"/&gt;
          &lt;/on-entry&gt;    
          &lt;transition on="salvaModificheBlocco" to="fine"&gt;
              &lt;evaluate expression="flowScope.blocchiBean.salvaBlocchi()"/&gt;
          &lt;/transition&gt;
      &lt;/view-state&gt;
  
      &lt;end-state id="fine" /&gt;
  
  &lt;/flow&gt;
  </code></pre>
  
  <p>I tried to understand which UI component was causing such an exception and, luckily, I was able to isolate it by launching the webapp on a debugging-mode server.
  Basically, it is a <code>&lt;script&gt;</code> node with 22 textElement children. The third child is causing the exception:</p>
  
  <pre><code>&lt;script&gt;
      |------ null_icefaces_config
      |------ ', '
      |------ null &lt;&lt;===== (This is the node which causes the exception. I mean exactly the null value associated to the "NULL type", here)
      |------ ', '
      |------ unknownWindow
      |------ [.. other children ..]
  </code></pre>
  
  <p>I also inspected the content of the <em>writer</em> object, which is the object containing the output stream that is gradually filled with the content of the response. The portion generated by rendering this element is:  </p>
  
  <pre><code>&lt;script&gt;ice.setupBridge('null_icefaces_config
  </code></pre>
  
  <p>Have you ever faced a similar problem? Do you think I should report this case to the ICEFaces staff, so that they can check whether it's a bug?</p>