10 Replies Latest reply on Aug 28, 2013 11:09 AM by Brian Leathem

    Error on glassfish 3.1.2 when using rich:fileupload

    hery deslandes Newbie

      Hello

      after upgrading glassfish 3.1.1 to 3.1.2, the rich:fileupload was broken. Same problem when using the apache common file upload library. I thnik that Glassfish has changed something in the implementation of servlet 3.0. Upload is working fine when using the servlet 3.0 api. I did not see a richfaces parameter or something to do. If i miss it, i apologize.

       

      • servlet code to take into account a new file (working fine)

      protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

                          Boolean isAuthenticated = (Boolean) req.getSession(true).getAttribute("isAuthenticated");

                        

       

                                    try {

                                              for (Part part : req.getParts()) {

                                                        String fileName = getFileName(part);

                                                        if (fileName != null) {

                                                                  logger.info(part.getName());

                                                                  InputStream is = req.getPart(part.getName()).getInputStream();

                                                                  logger.info("File name : " + fileName);

                                                                  saveUploadFile(is, fileName);

                                                                  is.close();

                                                        }

                                              }

                                    } catch (Exception e) {

                                              // TODO Auto-generated catch block

                                              e.printStackTrace();

                                              responseString = RESP_ERROR;

                                    }

      }

       

      • Richfaces Exception

       

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

                at org.richfaces.request.MultipartRequest25.parseIfNecessary(MultipartRequest25.java:77)

                at org.richfaces.request.MultipartRequest25.getParameter(MultipartRequest25.java:114)

                at com.sun.faces.context.RequestParameterMap.get(RequestParameterMap.java:75)

                at com.sun.faces.context.RequestParameterMap.get(RequestParameterMap.java:56)

                at java.util.Collections$UnmodifiableMap.get(Collections.java:1282)

                at com.sun.faces.application.view.MultiViewHandler.calculateRenderKitId(MultiViewHandler.java:220)

                at com.ocpsoft.pretty.faces.application.PrettyViewHandler.calculateRenderKitId(PrettyViewHandler.java:93)

                at javax.faces.application.ViewHandlerWrapper.calculateRenderKitId(ViewHandlerWrapper.java:155)

                at javax.faces.application.ViewHandlerWrapper.calculateRenderKitId(ViewHandlerWrapper.java:155)

                at com.sun.faces.context.FacesContextImpl.isPostback(FacesContextImpl.java:211)

                at javax.faces.context.FacesContextWrapper.isPostback(FacesContextWrapper.java:402)

                at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:188)

                at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

                at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)

                at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

                at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)

                at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)

                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)

                at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:175)

                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)

                at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)

                at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)

                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)

                at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)

                at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)

                at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:328)

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)

                at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)

                at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)

                at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)

                at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)

                at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)

                at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)

                at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)

                at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)

                at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)

                at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)

                at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)

                at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)

                at com.sun.grizzly.ContextTask.run(ContextTask.java:71)

                at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)

                at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)

                at java.lang.Thread.run(Thread.java:619)

      Caused by: java.io.IOException: Request prolog cannot be read

                at org.richfaces.request.MultipartRequestParser.readProlog(MultipartRequestParser.java:270)

                at org.richfaces.request.MultipartRequestParser.initialize(MultipartRequestParser.java:172)

                at org.richfaces.request.MultipartRequestParser.parse(MultipartRequestParser.java:148)

                ... 43 more

       

       

      Regards.