Thanks for confirming.
Martin
On 5/8/12 11:45 PM, Kevin Regan wrote:
>
> With a little more playing around I did get this to work. The
> configuration below will log headers while allow large files to be
> downloaded:
>
> <init-param>
>
> <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
>
> <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
>
> </init-param>
>
> <init-param>
>
> <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
>
> <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
>
> </init-param>
>
> <init-param>
>
> <param-name>com.sun.jersey.config.feature.logging.DisableEntitylogging</param-name>
>
> <param-value>true</param-value>
>
> </init-param>
>
> --Kevin
>
> *From:*Kevin Regan
> *Sent:* Tuesday, May 08, 2012 2:42 PM
> *To:* users_at_glassfish.java.net
> *Subject:* RE: Forcing chunked encoding while downloading a large file?
>
> Removing the logging filter fixed the problem. Thanks you.
>
> Removing the entire filter was necessary. Turning off the entity
> logging did not help. Might it be possible to implement this in such
> a way that headers could still be logged while the entity is just
> passed through?
>
> --Kevin
>
> *From:*Kevin Regan [mailto:k.regan_at_f5.com]
> <mailto:[mailto:k.regan_at_f5.com]>
> *Sent:* Tuesday, May 08, 2012 2:24 PM
> *To:* users_at_glassfish.java.net <mailto:users_at_glassfish.java.net>
> *Subject:* RE: Forcing chunked encoding while downloading a large file?
>
> Looking at the application, the logging filters were configured:
>
> <init-param>
>
> <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
>
> <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
>
> </init-param>
>
> <init-param>
>
> <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
>
> <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
>
> </init-param>
>
> Would adding the following cause the large downloaded file to be
> streamed rather than buffered?
>
> <init-param>
>
> <param-name>com.sun.jersey.config.feature.logging.DisableEntitylogging</param-name>
>
> <param-value>true</param-value>
>
> </init-param>
>
> Thanks,
>
> Kevin
>
> *From:*Martin Matula [mailto:martin.matula_at_oracle.com]
> <mailto:[mailto:martin.matula_at_oracle.com]>
> *Sent:* Tuesday, May 08, 2012 2:10 AM
> *To:* users_at_glassfish.java.net <mailto:users_at_glassfish.java.net>
> *Subject:* Re: Forcing chunked encoding while downloading a large file?
>
> Hi Kevin,
>
> That should not be happening. For InputStream Jersey returns -1 as the
> content length - i.e. does not try to buffer the entity. For the File
> it reads it using File.length() method.
>
> Are you using any filters in your application? E.g. the logging filter
> would cause that the entity would get buffered.
>
> Martin
>
> On May 4, 2012, at 11:24 PM, Kevin Regan wrote:
>
> I'm downloading a large file with Jersey/Glassfish and I'm seeing a
> java.lang.OutOfMemoryError.
>
> I'm returning a FileInputStream (also tried File) from the Jersey
> handler and it looks to be attempting to write the file to a
> ByteArrayOutputStream before returning it.
>
> Is there any way to force Jersey/Glassfish to stream this large binary
> file to the client through either chunked encoding or by not setting
> CONTENT-LENGTH?
>
> Sincerely,
>
> Kevin Regan
>