myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bbb123 <bradley_j_hug...@hotmail.com>
Subject Re: SizeLimitExceededException when uploading big files
Date Mon, 19 Oct 2009 18:53:14 GMT

Leonardo

Thank you for your solution. I was, however, finding it difficult to
implement the solution.

To anyone else who is having difficulty...

On the JSP page with my <t:inputFileUpload> tag, I added the following at
the top of the page:

<%@ page import="javax.faces.application.FacesMessage" %>
<%@ page import="javax.faces.context.FacesContext" %>

<%
        // This code allows for a check on the file size limit when trying
to do an attachment.
        Object fileUploadException = request.getAttribute(
"org.apache.myfaces.custom.fileupload.exception" );

        if ( fileUploadException != null )
        {
            String exceptionType = fileUploadException.toString();
            
            if ( exceptionType.equals( "sizeLimitExceeded" ) )
            {
                FacesMessage message = new FacesMessage(
FacesMessage.SEVERITY_WARN, "", "Attached File was rejected because the size
exceeds the maximum allowed attachment size." );
                FacesContext.getCurrentInstance().addMessage( null, message
);
            }
        }
%>

:
:
.
etc

So every time the page is loaded / submitted, the above code will run. If
the attribute that Leonardo created is set, then a message will be added to
the FacesContext, otherwise nothing will be displayed.

Make sure you are using:

tomahawk-1.1.9.jar
and
commons-fileupload-1.2.1.jar

Cheers
Brad H




Leonardo Uribe wrote:
> 
> 2009/7/22 António Rodrigues <antonio.jose.rodrigues@gmail.com>
> 
>> Thanks Leonardo
>>
>> This was a great help. However I am still facing the same problem.
>>
>> I have set the following parameters:
>>
>>    <filter>
>>        <filter-name>MyFacesExtensionsFilter</filter-name>
>>
>> 
>> <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
>>        <init-param>
>>            <param-name>uploadMaxFileSize</param-name>
>>            <param-value>4m</param-value>
>>        </init-param>
>>        <init-param>
>>            <param-name>uploadMaxSize</param-name>
>>            <param-value>10m</param-value>
>>        </init-param>
>>        <init-param>
>>            <param-name>cacheFileSizeErrors</param-name>
>>            <param-value>true</param-value>
>>        </init-param>
>>        <init-param>
>>            <param-name>uploadThresholdSize</param-name>
>>            <param-value>100k</param-value>
>>        </init-param>
>>    </filter>
>>
>>
>> The exception is not raised any more but the request still hangs when
>> I upload a file with size between uploadMaxFileSize and uploadMaxSize.
>> For some reason the request is not processed and the browser stands
>> loading the page forever.
>> With files smaller than uploadMaxFileSize everything works fine.
>>
> 
> Hi
> 
> Try the demo on TOMAHAWK-1381 (it is necessary to adjust tomahawk version
> to
> 1.1.9 in its pom.xml). It should work as described on the comments.
> 
> regards
> 
> Leonardo Uribe
> 
> 
>>
>> António
>>
>>
>> 2009/7/21 Leonardo Uribe <lu4242@gmail.com>:
>> > Hi
>> >
>> > Take a look at:
>> >
>> > https://issues.apache.org/jira/browse/TOMAHAWK-1381
>> > https://issues.apache.org/jira/browse/TOMAHAWK-1305
>> > https://issues.apache.org/jira/browse/TOMAHAWK-1420
>> >
>> > regards
>> >
>> > Leonardo Uribe
>> >
>> > 2009/7/21 António Rodrigues <antonio.jose.rodrigues@gmail.com>
>> >>
>> >> I am using Tomahawk 1.1.9 and Facelets.
>> >> When I upload files bigger than uploadMaxFileSize I get the following
>> >> exception.
>> >> The server never responds to the request and the browser keeps loading
>> >> the page infinitely.
>> >>
>> >> SizeLimitExceededException while uploading file.
>> >>
>> org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException:
>> >> the request was rejected because its size (5383438) exceeds the
>> >> configured maximum (4194304)
>> >>        at
>> >>
>> org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.<init>(FileUploadBase.java:914)
>> >>        at
>> >>
>> org.apache.commons.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:331)
>> >>        at
>> >>
>> org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:349)
>> >>        at
>> >>
>> org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:126)
>> >>        at
>> >>
>> org.apache.myfaces.webapp.filter.MultipartRequestWrapper.parseRequest(MultipartRequestWrapper.java:136)
>> >>        at
>> >>
>> org.apache.myfaces.webapp.filter.MultipartRequestWrapper.getParameter(MultipartRequestWrapper.java:274)
>> >>        at
>> >>
>> com.sun.faces.context.RequestParameterMap.get(ExternalContextImpl.java:1135)
>> >>        at
>> >>
>> com.sun.faces.context.RequestParameterMap.get(ExternalContextImpl.java:1120)
>> >>        at
>> java.util.Collections$UnmodifiableMap.get(Collections.java:1282)
>> >>        at
>> >>
>> com.sun.faces.application.ViewHandlerImpl.calculateRenderKitId(ViewHandlerImpl.java:512)
>> >>        at
>> >>
>> com.sun.facelets.FaceletViewHandler.calculateRenderKitId(FaceletViewHandler.java:792)
>> >>        at
>> >>
>> com.sun.faces.lifecycle.RestoreViewPhase.isPostback(RestoreViewPhase.java:267)
>> >>        at
>> >>
>> com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:137)
>> >>        at
>> >> com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
>> >>        at
>> >> com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
>> >>        at
>> javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
>> >>        at
>> >>
>> org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
>> >>        at
>> >>
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
>> >>        at
>> >>
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
>> >>        at
>> >>
>> org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:341)
>> >>        at
>> >>
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
>> >>        at
>> >>
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
>> >>        at
>> >>
>> org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
>> >>        at
>> >>
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
>> >>        at
>> >>
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
>> >>        at
>> >>
>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:288)
>> >>        at
>> >>
>> org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
>> >>        at
>> >>
>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
>> >>        at
>> >>
>> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
>> >>        at
>> >>
>> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
>> >>        at
>> com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
>> >>        at
>> >>
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
>> >>        at
>> >>
>> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
>> >>        at
>> >>
>> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
>> >>        at
>> >>
>> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
>> >>        at
>> >> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
>> >>        at
>> >>
>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
>> >>        at
>> >>
>> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
>> >>        at
>> >>
>> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
>> >>        at
>> >>
>> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
>> >>        at
>> >> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
>> >>        at
>> >>
>> org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
>> >>        at
>> >>
>> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
>> >>        at
>> >>
>> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
>> >>        at
>> >>
>> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
>> >>        at
>> >>
>> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
>> >>        at
>> >>
>> com.sun.enterprise.web.connector.grizzly.ssl.SSLReadTask.process(SSLReadTask.java:440)
>> >>        at
>> >>
>> com.sun.enterprise.web.connector.grizzly.ssl.SSLReadTask.doTask(SSLReadTask.java:228)
>> >>        at
>> >>
>> com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
>> >>        at
>> >>
>> com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
>> >>
>> >>
>> >> Any hint would be appreciated.
>> >>
>> >> Thanks
>> >> António
>> >
>> >
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/SizeLimitExceededException-when-uploading-big-files-tp24589875p25963566.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Mime
View raw message