2 Replies Latest reply on Dec 16, 2013 5:01 PM by Sam Sam

    <rich:fileUpload> Fails on Glassfish 4

    Sam Sam Newbie

      I'm relatively new to Java EE, Glassfish 4 and Richfaces 4.3.1 and whilst I have managed to resolve many problems with the first two of these technologies Richfaces has tripped me up right from the very start. I am trying to do a simple file upload web page using the <rich:fileupload> tag but when I click the upload button I get an exception thrown:

       

      SEVERE:   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)
      

       

       

      Now I have seen this question raised in several places but so far they seem only to refer to JBoss server and a fix for it but I am not using that. For example here.

       

      This is my relevant code which fails:

       

      web.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
          <context-param>
              <param-name>org.richfaces.fileUpload.createTempFiles</param-name>
              <param-value>false</param-value>
          </context-param>
          <context-param>
              <param-name>org.richfaces.fileUpload.maxRequestSize</param-name>
              <param-value>100000</param-value>
          </context-param>
          <servlet>
              <servlet-name>Upload Servelet</servlet-name>
              <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
          </servlet>
          <servlet-mapping>
              <servlet-name>Upload Servelet</servlet-name>
              <url-pattern>*.faces</url-pattern>
          </servlet-mapping>
          <session-config>
              <session-timeout>
                  30
              </session-timeout>
          </session-config>
      </web-app>
      

       

      uploadfile.xhtml

       

      And finally UploadBean.java

      package com.test.richfacestesting;
      
      import javax.ejb.Stateless;
      import javax.faces.bean.RequestScoped;
      import javax.inject.Named;
      import org.richfaces.event.FileUploadEvent;
      import org.richfaces.event.FileUploadListener;
      
      
      @Named
      @RequestScoped
      public class UploadBean implements FileUploadListener{
      
          @Override
          public void processFileUpload(FileUploadEvent fue) {
              throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
          }
         
          
      }
      
      

       

      Could enyone tell me what I'm doing wrong or how to resolve this? It appears to have been a problem in Glassfish 3 as well.