users@jersey.java.net

Re: [Jersey] Very Large files causing java Out of Memory error

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 10 Mar 2009 11:22:52 +0100

On Mar 9, 2009, at 9:00 PM, jmiller wrote:

>
> It is an InputStream.
>

What is the complete method signature?

     @POST
     @Path("postbigfile")
     @Consumes(MediaType.MULTIPART_FORM_DATA)
     @Produces("text/plain")
     public XXX post(@FormParam("xxx") InputStream xxx) {
     }

?

I think the problem is due to JavaMail is buffering the contents of a
body part, probably because to process form parameters Jersey needs to
analyze all the headers in the body part and create a map of names to
body parts, for example if you have more than one @FormParam declared
the parameters might not be declared in the same order as the
corresponding body parts.

We do have another API that supports caching stuff to disk. It uses
the JavaMail API but processes body parts linearly and so may not
buffer (i have not verified if this is the case).

Could you try with that and see if it resolves your issue?

See:

     https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0.2/api/contribs/jersey-multipart/index.html
     https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0.2/jersey/dependencies.html

     @POST
     @Path("postbigfile")
     @Consumes(MediaType.MULTIPART_FORM_DATA)
     @Produces("text/plain")
     public XXX post(FormDataMultiPart f) {
         try {
         } finally {
             f.cleanup();
         }
     }

We are planning to transition over @FormParam support, or use another
annotation instead, to using this API [1].

Paul.

[1] http://markmail.org/search/?q=list
%3Anet.java.dev.jersey.users#query:list%3Anet.java.dev.jersey.users
+page:1+mid:ovcldpxf4oebupmr+state:results

>
> Marc Hadley wrote:
>>
>> Sounds like you are running into an issue where the input is being
>> buffered before the method is dispatched. What is the Java type of
>> the
>> argument that represents the entity in your method, have you tried
>> using java.io.File instead ?
>>
>> Marc.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>>
>>
>
> --
> View this message in context: http://n2.nabble.com/Very-Large-files-causing-java-Out-of-Memory-error-tp2446303p2451302.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>