title: NullPointerException at setCharacterEncoding(UploadRequestWrapper.java:83)
body: <p>I am trying to upload a file to server using trinidad fileupload (<a href="https://myfaces.apache.org/trinidad/devguide/fileUpload.html" rel="nofollow">tr:inputFile</a>) component but i get a </p>
  
  <blockquote>
    <p>NullPointerException at setCharacterEncoding(UploadRequestWrapper.java:83)</p>
  </blockquote>
  
  <p>on pressing the commandButton.</p>
  
  <p>My <strong>XHTML file</strong> contains:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:tr="http://myfaces.apache.org/trinidad" &gt;
  &lt;ui:composition template="/WEB-INF/templates/BasicTemplate.xhtml"&gt;
  
      &lt;ui:define name="content"&gt;
          &lt;tr:form usesUpload="true"&gt;
              &lt;tr:inputFile label="Upload:" valueChangeListener="#{myBackingBean.fileUploaded}"/&gt;
              &lt;tr:commandButton text="Begin"/&gt;
          &lt;/tr:form&gt;
      &lt;/ui:define&gt;
  
      &lt;/ui:define&gt;
  &lt;/ui:composition&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>the Backing Bean:</strong></p>
  
  <pre><code>import javax.faces.application.FacesMessage;
  import javax.faces.context.FacesContext;
  import javax.faces.event.ValueChangeEvent;
  import org.apache.myfaces.trinidad.model.UploadedFile;
  
  public class MyBackingBean{
      ...
      public void fileUploaded(ValueChangeEvent event){
          UploadedFile file = (UploadedFile) event.getNewValue();
          if (file != null){
              FacesContext context = FacesContext.getCurrentInstance();
              FacesMessage message = new FacesMessage(
                  "Successfully uploaded file " + file.getFilename() +
                  " (" + file.getLength() + " bytes)");
                  context.addMessage(event.getComponent().getClientId(context), message);
                  // Here's where we could call file.getInputStream()
          }
      }
  }
  </code></pre>
  
  <p><strong>the WEB-INF/web.xml file:</strong></p>
  
  <pre><code>&lt;filter&gt;
      &lt;filter-name&gt;trinidad&lt;/filter-name&gt;
      &lt;filter-class&gt;org.apache.myfaces.trinidad.webapp.TrinidadFilter&lt;/filter-class
  &lt;/filter&gt;
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;faces&lt;/servlet-name&gt;
      &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;trinidad&lt;/filter-name&gt;
      &lt;servlet-name&gt;faces&lt;/servlet-name&gt;
  &lt;/filter-mapping&gt;
  </code></pre>
  
  <p><strong>I am using:</strong></p>
  
  <ol>
  <li>Server: Tomcat 7.0.12</li>
  <li>MyFaces 2.2.0</li>
  <li>Trinidad 2.0.1</li>
  <li>JSTL 1.2</li>
  <li>Eclipse Java EE IDE for Web Developers / Version: Kepler Service Release 1</li>
  </ol>
  
  <p><strong>Full output:</strong></p>
  
  <pre><code>Schwerwiegend: Servlet.service() for servlet [Faces Servlet] in context with path [/com.cargarantie.ws.claimshandler] threw exception [null] with root cause java.lang.NullPointerException
  at org.apache.myfaces.trinidadinternal.config.upload.UploadRequestWrapper.setCharacterEncoding(UploadRequestWrapper.java:83)
  at org.apache.myfaces.context.servlet.ServletExternalContextImpl.setRequestCharacterEncoding(ServletExternalContextImpl.java:581)
  at javax.faces.context.ExternalContextWrapper.setRequestCharacterEncoding(ExternalContextWrapper.java:416)
  at javax.faces.context.ExternalContextWrapper.setRequestCharacterEncoding(ExternalContextWrapper.java:416)
  at javax.faces.application.ViewHandler.initView(ViewHandler.java:339)
  at org.apache.myfaces.application.ViewHandlerImpl.initView(ViewHandlerImpl.java:191)
  at javax.faces.application.ViewHandlerWrapper.initView(ViewHandlerWrapper.java:49)
  at org.apache.myfaces.lifecycle.RestoreViewExecutor.doPrePhaseActions(RestoreViewExecutor.java:83)
  at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:182)
  at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:143)
  at javax.faces.webapp.FacesServlet.service(FacesServlet.java:196)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
  at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
  at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>Any ideas? Thanks in advance.</p>