3 Replies Latest reply on Dec 10, 2012 2:25 AM by Eric Jia

    Seam 2.3 rich:fileupload

    Jubril Adisa Novice

      I keep getting the exception below while trying to upload a file

       

      5:52:30,689 SEVERE [org.richfaces.log.Application] (http-localhost-127.0.0.1-8080-2) Exception parsing multipart request: Request prolog cannot be read: org.richfaces.exception.FileUploadException: Exception parsing multipart request: Request prolog cannot be read

                at org.richfaces.request.MultipartRequestParser.parse(MultipartRequestParser.java:156) [richfaces-components-ui.jar:4.2.2.Final]

                at org.richfaces.request.MultipartRequest25.parseIfNecessary(MultipartRequest25.java:77) [richfaces-components-ui.jar:4.2.2.Final]

                at org.richfaces.request.MultipartRequest25.getParameter(MultipartRequest25.java:114) [richfaces-components-ui.jar:4.2.2.Final]

       

      I am using Jboss 7.2, Seam 2.3, Richfaces4.2.2

       

       

      This is the configuration i have made so far

       

      web.xml

       

       

      <filter>

            <filter-name>Seam Filter</filter-name>

            <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>

            <init-param>

                <param-name>createTempFiles</param-name>

                <param-value>false</param-value>

            </init-param>

            <init-param>

                <param-name>maxRequestSize</param-name>

                <param-value>2000000</param-value>

            </init-param>

           

         </filter>

       

       

      <h:form  enctype="multipart/form-data">

                                        <rich:fileUpload   style="margin: 2em auto;" fileUploadListener="#{uploadImages.listener()}" acceptedTypes="jpg, gif, png, bmp"                          maxFilesQuantity="50000"  ontyperejected="alert('Only JPG, GIF, PNG and BMP files are accepted');" >

                                          </rich:fileUpload>

                          </h:form>

       

      Any Suggestions will be appreciated

        • 1. Re: Seam 2.3 rich:fileupload
          duc tun vu Newbie

          Hi,

           

          We have the same stack as you and also suffering from this issue with rich:fileUpload component. Did you find any solution for it?

           

          Thanks you!

          • 2. Re: Seam 2.3 rich:fileupload
            duc tun vu Newbie

            For me, disable the built-in Seam's MultipartFilter did help!

             

            To disable MultipartFilter, you need the following line in components.xml:

             

                 <web:multipart-filter disabled="true"/>

             

            Futher, my web.xml has following Richfaces-specific context-params for the fileUpload component:

             

                 <context-param>

                        <param-name>org.richfaces.fileUpload.maxRequestSize</param-name>

                        <param-value>2000000</param-value>

                </context-param>

                <context-param>

                        <param-name>org.richfaces.fileUpload.createTempFiles</param-name>

                        <param-value>false</param-value>

                </context-param>

             

             

            This configuration worked for me, my stack: Seam 2,3, Richfaces 4.2.2-Final, JBoss 7.1

             

            Good luck!

            • 3. Re: Seam 2.3 rich:fileupload
              Eric Jia Newbie

              The configuration works for me too.

              But I got another problem in richfaces fileupload component. plz help me.

              my jsf page code:

              ....

              <h:form>

                <rich:fileUpload fileUploadListener="#{richUploadListener.upload}">

              </rich:fileUpload>

              </h:form>

              ...

               

              my java code

               

               

              ....

              @Local

              public interface IRichUploadListener {

                   void upload();

                   void upload(FileUploadEvent event);

              }

               

              @Stateless

              @Name("richUploadListener")

              public class RichUploadListener implements IRichUploadListener {

               

                  @Override

                  public void upload(FileUploadEvent event) {

                         System.out.println("do upload");

                  }

               

                  @Override

                  public void upload() {

                       System.out.println("do upload with no param");//print this;

                  }

               

              }

               

               

               

              The richfaces uploadfile component called public void upload();

              How can i get the event param (FileUploadEvent)?