6 Replies Latest reply on Jan 20, 2011 5:56 AM by oliverg

    fileUpload with JSF 2 and RF 3.3.3

    oliverg

      Hello,

       

      we were using the rich:fileUpload component together with JSF 1.2 and it worked perfect. Now we tried to upgrade to JSF 2 and most RF components are still working nice.

       

      But now rich:fileUpload seem to have problems with uploads greater than ca. 3 MB (not easy to reproduce on local testing, occurs if you are accessing via limited (upload-) bandwith like some hundreds KB/s). This exception occurs when the upload status bar is complete:

       

       

      ... ERROR [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/].[Faces Servlet].invoke:274] Servlet.service() for servlet Faces Servlet threw exception

      javax.faces.application.ViewExpiredException: .../upload.jsfNo saved view state could be found for the view identifier: .../upload.jsf

      at org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:128) ...

       

      Has anyone got similar problems or do know what can help? (Use of RF 4 not possible until not final)

      Thank you!

       

      Environment: Tomcat 6 on JRE 6, RF 3.3.3 Final, JSF 2, Spring 3

        • 1. fileUpload with JSF 2 and RF 3.3.3
          oliverg

          BTW: web.xml settings are okay. We prooved that this is not a problem of limited session timeout or limited upload size.

          • 2. fileUpload with JSF 2 and RF 3.3.3
            ilya40umov

            javax.faces.application.ViewExpiredException means that a user's session has expired. You can try to increase time of the session for your application.

            The following strings should do the trick:

            <session-config>

                            <session-timeout>120</session-timeout>

                    </session-config>

            Or you can try HttpSession setMaxInactiveInterval as an alternative.

            • 3. fileUpload with JSF 2 and RF 3.3.3
              oliverg

              As I mentioned above, the session-timeout has a high value in web.xml and the upload of some MB fails after 2 or 3 minutes (after login).

               

              BTW: The handling bean has request scope and KeepAlive-Annotation

              • 4. fileUpload with JSF 2 and RF 3.3.3
                ilya40umov

                Hm. If you are using KeepAlive-Annotation this question will be answered better by RF team.

                • 5. fileUpload with JSF 2 and RF 3.3.3
                  ilya_shaikovsky

                  please show the code.

                  • 6. Re: fileUpload with JSF 2 and RF 3.3.3
                    oliverg

                    We found a little trade-off: we set allowFlash="auto". Then big file uploads work for guys who have Flash in their browser (but not if they have no Flash). In our case, we cannot be sure if all customers have Flash-Plugin, but the probabillity is high, i think.

                     

                    Previous code:

                     

                    {code}

                    <rich:fileUpload id="fileUpload" locale="#{sessionBean.language}" maxFilesQuantity="#{bean.uploadsAvailable}"

                              allowFlash="false" status="waitStatus" fileUploadListener="#{bean.listener}" ajaxSingle="true"

                              doneLabel="#{labels.rich_fileUpload_done}" listHeight="65px" immediateUpload="true"

                              transferErrorLabel="#{bean.transferError}" transferErrorLabelClass="fileUploadTransferError"

                              sizeErrorLabel="#{messages.bean_file_maxsize}" sizeErrorLabelClass="fileUploadTransferError"

                              acceptedTypes="#{bean.acceptedTypes}">

                              <a4j:support event="onclear" reRender="fileUpload,uploadPanelSelect" action="#{bean.clear}" ajaxSingle="true" />

                              <a4j:support event="onfileuploadcomplete" reRender="uploadPanelSelect" limitToList="true" />

                              <a4j:support event="ontyperejected" reRender="uploadForm" action="#{bean.onTypeRejected}" ajaxSingle="true" />

                              <f:facet name="label">

                                <h:outputText

                                  value="{_MB} MB #{labels.rich_fileUpload_from} {MB} MB #{labels.rich_fileUpload_uploaded} ({mm}:{ss})" />

                              </f:facet>

                    </rich:fileUpload>

                    {code}

                     

                     

                    {code}

                      public void listener(final UploadEvent event) {

                        if (event.getUploadItem() == null) return;

                        setUploadItem(event.getUploadItem());

                        uploadsAvailable--;

                      }

                    {code}

                     

                     

                    Some web.xml settings:

                    {code}

                    <context-param>

                        <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>

                        <param-value>com.sun.facelets.FaceletViewHandler</param-value>

                      </context-param>

                     

                      <filter>

                        <display-name>Ajax4jsf Filter</display-name>

                        <filter-name>ajax4jsf</filter-name>

                        <filter-class>org.ajax4jsf.Filter</filter-class>

                        <init-param>

                          <param-name>forceparser</param-name>

                          <param-value>true</param-value>

                        </init-param>

                        <init-param>

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

                          <param-value>true</param-value>

                        </init-param>

                        <init-param>

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

                          <param-value>1000000000</param-value>

                        </init-param>

                      </filter>

                     

                      <filter-mapping>

                        <filter-name>ajax4jsf</filter-name>

                        <servlet-name>Faces Servlet</servlet-name>

                        <dispatcher>REQUEST</dispatcher>

                        <dispatcher>FORWARD</dispatcher>

                        <dispatcher>INCLUDE</dispatcher>

                      </filter-mapping>

                    {code}