title: NullPointerException is thrown when Custom ViewHandler is used
body: <p>I'm trying to use a custom ViewHandler in my application built with JSF2, PrimeFaces 3.2.x and deployed on Glassfish AS v3.1.1. Once I added my custom ViewHandler in faces-config.xml, the first page is rendered fine, but any action leads to NPE. I modified my ViewHandler so it does nothing but proxying to a parent ViewHandler, but the problem persists.</p>
  
  <p>The code for CustomViewHandler   </p>
  
  <pre><code>import java.io.IOException;
  import java.util.Locale;
  import javax.faces.FacesException;
  import javax.faces.application.ViewHandler;
  import javax.faces.component.UIViewRoot;
  import javax.faces.context.FacesContext;
  
  public class CustomViewHandler extends ViewHandler {
      private ViewHandler parent;
  
      public CustomViewHandler(ViewHandler parent) {
          this.parent = parent;
      }
  
      @Override
      public UIViewRoot restoreView(FacesContext facesContext, String viewId) {
          return parent.restoreView(facesContext, viewId);
      }
  
      @Override
      public Locale calculateLocale(FacesContext facesContext) {
          return parent.calculateLocale(facesContext);
      }
  
      @Override
      public String calculateRenderKitId(FacesContext facesContext) {
          return parent.calculateRenderKitId(facesContext);
      }
  
      @Override
      public UIViewRoot createView(FacesContext facesContext, String viewId) {
          return parent.createView(facesContext, viewId);
      }
  
      @Override
      public String getActionURL(FacesContext facesContext, String actionId) {
          return parent.getActionURL(facesContext, actionId);
      }
  
      @Override
      public String getResourceURL(FacesContext facesContext, String resId) {
          return parent.getResourceURL(facesContext, resId);
      }
  
      @Override
      public void renderView(FacesContext facesContext, UIViewRoot viewId) throws IOException, FacesException {
          parent.renderView(facesContext, viewId);
  
      }
  
      @Override
      public void writeState(FacesContext facesContext) throws IOException {
          parent.writeState(facesContext);
      }
  
      public ViewHandler getParent() {
          return parent;
      }
  }
  </code></pre>
  
  <p>My faces-config.xml</p>
  
  <pre><code>&lt;application&gt;
      &lt;view-handler&gt;com.util.CustomViewHandler&lt;/view-handler&gt;
      &lt;message-bundle&gt;messages&lt;/message-bundle&gt;
      &lt;locale-config&gt;
          &lt;default-locale&gt;en&lt;/default-locale&gt;
          &lt;supported-locale&gt;en&lt;/supported-locale&gt;
      &lt;/locale-config&gt;
      &lt;resource-bundle&gt;
         &lt;base-name&gt;messages&lt;/base-name&gt;
         &lt;var&gt;msg&lt;/var&gt;
       &lt;/resource-bundle&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p>Stacktrace</p>
  
  <pre><code>java.lang.NullPointerException
  at javax.faces.component.UIComponentBase.getRenderer(UIComponentBase.java:1402)
  at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:785)
  at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1181)
  at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1176)
  at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1176)
  at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:933)
  at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
  at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
  at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
  at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
  at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
  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:217)
  at com.seer.filter.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:21)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
  at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
  at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
  at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
  at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
  at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
  at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:232)
  at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
  at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
  at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
  at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
  at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
  at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
  at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
  at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
  at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
  at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
  at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
  at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
  at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
  at java.lang.Thread.run(Thread.java:722)
  </code></pre>
  
  <p>Thanks</p>