1 Reply Latest reply on Oct 22, 2010 2:36 AM by Jean-Frederic Clere

    request.getParts throws NPW

    Nicklas Karlsson Master

      Hi,

       

      I'm trying to use file uploads with JSF 2 on a M5 and wrap a request from a filter (when a multipart-request is detected) with something like

       

      public class MultipartRequestWrapper extends HttpServletRequestWrapper {
          private static final String CONTENT_DISPOSITION = "content-disposition";
          private static final String CONTENT_DISPOSITION_FILENAME = "filename";
          private Hashtable<String, String[]> params = new Hashtable<String, String[]>();
          public MultipartRequestWrapper(HttpServletRequest request) {
              super(request);
              System.out.println("Created multipart wrapper....");
              try {
                  System.out.println("Looping parts");           
                  for (Part p : request.getParts()) {

      public class MultipartRequestWrapper extends HttpServletRequestWrapper {

          public MultipartRequestWrapper(HttpServletRequest request) {

               for (Part p : request.getParts()) {

      ...

       

      but I end up with a

       

      17:57:39,820 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/upload].[FacesServlet]] Servlet.service() for servlet FacesServlet threw exception: java.lang.NullPointerException

      at org.apache.catalina.connector.Request.getParts(Request.java:3233) [:]

      at org.apache.catalina.connector.RequestFacade.getParts(RequestFacade.java:1112) [:]

      at nik.http.MultipartRequestWrapper.<init>(MultipartRequestWrapper.java:32) [:]

      at nik.http.MultipartRequestFilter.doFilter(MultipartRequestFilter.java:34) [:]

      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:]

      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:]

      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:]

      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [:]

      ...

       

      Are you supposed to be able to use getParts like this or is it just for stuff like @MultipartConfig servlets?