Results 1 to 5 of 5

Thread: Fileupload (Multipart) problem - Exception early thrown, but lately shown

  1. #1
    Join Date
    Sep 2008
    Posts
    12

    Angry Fileupload (Multipart) problem - Exception early thrown, but lately shown

    Hallo,

    Unfortunately I have a problem, where I don't really know what the problem actually is. Like many others I have a problem with file upload. But it's not how to get a file upload work, it's more how to prevent a file upload, in case a MultipartException was thrown.

    First, let me tell something about my setup;

    In the spring context, I have the std. CommonsMultipartResolver:
    Code:
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
          <property name="maxUploadSize" value="5242880"/>             
    </bean>
    In connection with that I am using the current Apache Commons Fileupload release (1.2.1). Anything behind that doesn't seem to be noteworthy, because my problem occurs before the controller is involved.


    The thing is that the fileupload itself is working fine, but:

    when a MaxUploadSizeExceededException is thrown, which is raised at last by the class' CommonsMultipartResolver parseRequest() method, the file upload is processed _anyway_!

    So data is actually transfered at its full size, and after that the view is resolved and delegated back to the browser, although the exception is thrown immediately while the parseRequest() method executes its try block.

    I watched this in the debugger and the Netbeans profiler(screenshot attached). During that I perceived, that transferring of the file data not startet yet. I also put the commons fileupload sources into my project to watch its behavior, with the result that during my watching time no stream was invoked. So after parseRequest() has thrown the Exception the debugger got to the exception resolver, my filters and stepped out. Having no more control, not sseing what happens now, the file transfer starts. (Could see that in the network tab of Win task manager). After the whole file is transfered the view appears in the browser. Even if I don't resolve the exception, you have to wait as well for the stack trace, given by the Tomcat server.

    So, it seems to me apache fileupload is working correctly.
    I think there is another thread working, processing the stream, but for god's sake I don't know how and why, searching and trying for almost one week until today.


    Currently, I'm using Spring 2.5.6, because I guessed there was a problem when upgrading to Commons Fileupload 1.2.1, because of the following issue:

    hyperTextTransferProtocol://issues.apache.org/jira/browse/FILEUPLOAD-145

    The webserver I am using is Tomcat 6.0.18.

    I really hope some of you have an idea what this could be about, kindly thanking in advance.

    Good night.

    /wthomas

    Attachment:

    Stack Trace:


    Code:
    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size of 5242880 bytes exceeded; nested exception is org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (228445001) exceeds the configured maximum (5242880)
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:583)
    	org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	de.....filters.IsInRoleFilter.doFilter(IsInRoleFilter.java:60)
    	de.....filters.LastReqUrlFilter.doFilter(LastReqUrlFilter.java:41)
    	de.....filters.LocaleFilter.doFilter(LocaleFilter.java:43)
    
    root cause
    
    org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size of 5242880 bytes exceeded; nested exception is org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (228445001) exceeds the configured maximum (5242880)
    	org.springframework.web.multipart.commons.CommonsMultipartResolver.parseRequest(CommonsMultipartResolver.java:169)
    	org.springframework.web.multipart.commons.CommonsMultipartResolver.resolveMultipart(CommonsMultipartResolver.java:149)
    	org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1012)
    	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:853)
    	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
    	org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	de......filters.IsInRoleFilter.doFilter(IsInRoleFilter.java:60)
    	de......filters.LastReqUrlFilter.doFilter(LastReqUrlFilter.java:41)
    	de......filters.LocaleFilter.doFilter(LocaleFilter.java:43)
    
    root cause
    
    org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (228445001) exceeds the configured maximum (5242880)
    	org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.<init>(FileUploadBase.java:914)
    	org.apache.commons.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:331)
    	org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:349)
    	org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:126)
    	org.springframework.web.multipart.commons.CommonsMultipartResolver.parseRequest(CommonsMultipartResolver.java:165)
    	org.springframework.web.multipart.commons.CommonsMultipartResolver.resolveMultipart(CommonsMultipartResolver.java:149)
    	org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1012)
    	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:853)
    	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
    	org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	de.....filters.IsInRoleFilter.doFilter(IsInRoleFilter.java:60)
    	de.....filters.LastReqUrlFilter.doFilter(LastReqUrlFilter.java:41)
    	de.....filters.LocaleFilter.doFilter(LocaleFilter.java:43)
    Attached Images Attached Images

  2. #2
    Join Date
    Sep 2008
    Posts
    12

    Default Possible reasons shrinked

    Hallo,

    it's me again.

    I got a little bit closer to the problem, but still have no solution :/

    The described situation above also appears if I don't have any MultipartResolver registered.
    I think the problem is caused by some binding action in the AbstractWizardFormController. Do I change the enctype in the jsp, claiming there is no multipart, the upload does not occur.

    But now the question is, how can I suppress this behaviour, processing the file upload by myself and let the form text data bind by the controller?

    Thanks, for at least reading this..

    Regards..

    wthomas

  3. #3
    Join Date
    May 2006
    Posts
    9

    Default Same problem

    I am having the exact same problem using the CommonsMultipartResolver and an AbstractWizardFormController. I know the exception is caught right away, but the form continues to submit the entire file. Any one have any idea why this is happening? This can't be the intended behavior.

  4. #4
    Join Date
    Sep 2008
    Posts
    12

    Default

    Hi SSJ2Joseph,

    have a look at this thread:
    hateeteepee://forum.springframework.org/showthread.php?t=60869

    Regards..

  5. #5
    Join Date
    Nov 2007
    Posts
    25

    Default

    Did you ever figure out a solution for this? I added a request listener to demarcate the lifespan of the request and determined that it continues to upload after the request has exited Tomcat. I'm starting to wonder if this has anything to do with AJP since mine is running behind apache.

    Do you have a similiar setup?

    Quote Originally Posted by SSJ2Joseph View Post
    I am having the exact same problem using the CommonsMultipartResolver and an AbstractWizardFormController. I know the exception is caught right away, but the form continues to submit the entire file. Any one have any idea why this is happening? This can't be the intended behavior.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •