2 Replies Latest reply on Sep 28, 2010 7:47 PM by zradick

    rich:fileUpload FileUploadException: IO Error parsing multipart request

    zradick

      We are in the process of converting a large application using JSF1.2(MyFaces)/JSP with RichFaces 3.3.2 running on JBoss 5.1.0GA to JSF2(Mojarra 2.0.2)/Facelets with RichFaces 3.3.3-Final running on Tomcat 6.0.29.  Most of this is completed and seems to be working properly, however I am getting an exception when trying to use the rich:fileUpload component.  Here is the stack trace from my Tomcat logs:

       

      SEVERE: Servlet.service() for servlet Faces Servlet threw exception
      org.ajax4jsf.exception.FileUploadException: IO Error parsing multipart request
          at org.ajax4jsf.request.MultipartRequest.parseRequest(MultipartRequest.java:388)
          at org.ajax4jsf.request.MultipartRequest.getParameterMap(MultipartRequest.java:656)
          at org.apache.myfaces.webapp.filter.MultipartRequestWrapper.parseRequest(MultipartRequestWrapper.java:135)
          at org.apache.myfaces.webapp.filter.MultipartRequestWrapper.getParameter(MultipartRequestWrapper.java:182)
          at com.sun.faces.context.RequestParameterMap.get(RequestParameterMap.java:71)
          at com.sun.faces.context.RequestParameterMap.get(RequestParameterMap.java:52)
          at java.util.Collections$UnmodifiableMap.get(Collections.java:1282)
          at org.ajax4jsf.context.AjaxContextImpl.decode(AjaxContextImpl.java:135)
          at org.ajax4jsf.context.AjaxContext.getCurrentInstance(AjaxContext.java:210)
          at org.richfaces.context.PartialViewContextFactoryImpl.getPartialViewContext(PartialViewContextFactoryImpl.java:46)
          at com.sun.faces.context.FacesContextImpl.getPartialViewContext(FacesContextImpl.java:188)
          at com.sun.faces.context.ExceptionHandlerFactoryImpl.getExceptionHandler(ExceptionHandlerFactoryImpl.java:61)
          at com.sun.faces.context.FacesContextFactoryImpl.getFacesContext(FacesContextFactoryImpl.java:98)
          at org.apache.myfaces.webapp.filter.TomahawkFacesContextFactory.getFacesContext(TomahawkFacesContextFactory.java:107)
          at com.sun.faces.context.InjectionFacesContextFactory.getFacesContext(InjectionFacesContextFactory.java:101)
          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:302)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:301)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
          at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
          at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:367)
          at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:563)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
          at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861)
          at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
          at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584)
          at java.lang.Thread.run(Thread.java:619)
      Caused by: java.io.IOException: Request prolog cannot be read
          at org.ajax4jsf.request.MultipartRequest.readProlog(MultipartRequest.java:333)
          at org.ajax4jsf.request.MultipartRequest.initialize(MultipartRequest.java:369)
          at org.ajax4jsf.request.MultipartRequest.parseRequest(MultipartRequest.java:379)
          ... 37 more

       

      This was working previously in the aforementioned environment.  I looked around but did not see other people mentioning this error.  Has anyone encountered this before or have any suggestions where I might start looking?

       

      Thanks,

      --Zack

        • 1. Re: rich:fileUpload FileUploadException: IO Error parsing multipart request
          zradick

          Stepping through the code during execution it appears that the Tomahawk FileUploadBase class is somehow getting involved and reading the bytes from Tomcat's CoyoteInputStream before the a4j ByteSequenceMatcher gets it's chance.  When the ByteSequenceMatcher goes to fill it's buffer from the InputStream while reading the prolog, the stream returns -1 (EOF) and the process aborts.  If anyone has seen this behavior and has suggestions, please let me know.

          • 2. Re: rich:fileUpload FileUploadException: IO Error parsing multipart request
            zradick

            Disabling the Tomahawk extensions filter fixes this issue.  However it means that we cannot use several of the Tomahawk features that we were previously using.

             

            Having searched the forums a bit it is clear that this is a Tomahawk failing (using a Servlet Filter to handle a component, for shame) and that the reason this worked previously was due to workarounds put in place by the RichFaces folks.  I would guess that these workarounds were not included in the RF3.3.3-Final, but were a part of the 3.2 release, which is why this previously worked.  Unfortunately this leaves me the task of removing any component that requires the Tomahawk extensions filter or replacing the rich:fileUpload.  Given the limitations that cannot be avoided using the Tomcat extensions filter I will opt to cut it out of the picture, but it is an unfortunate setback.

             

            Hope this helps others who encounter this.

            --Zack