users@jersey.java.net

[Jersey] Re: JSON Compression from JAX-RS in Glassfish

From: Ronak Patel <ronak2121_at_yahoo.com>
Date: Thu, 9 Dec 2010 08:27:46 -0800 (PST)

Thanks Paul,


I switched to the GZIPContentEncodingFilter...is there any way of knowing
whether it's actually being invoked? Do I need to put a specific logger into
debug? I looked through the source for that class but I don't see any logging
statements...

The intermittent compression problems seem to have gone away...but I cannot
verify until I know that compression is actually working....

This is what I did in my web.xml file:

      
<servlet>
<servlet-name>profile-service</servlet-name>
<servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>

<!-- Turn on GZIP Compression -->
<init-param>
<param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
<param-value>com.sun.jersey.api.container.filter.GZIPContentEncodingFilter</param-value>

</init-param>
</servlet>

Thanks

Ronak Patel



________________________________
From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
To: users_at_glassfish.java.net
Cc: users_at_glassfish.dev.java.net; users_at_jersey.java.net
Sent: Wed, December 8, 2010 1:03:20 AM
Subject: Re: JSON Compression from JAX-RS in Glassfish

Hi Ronak,

I have not. Can you confirm this the case when only using JSON?

One thing you might be able to do is enable Jersey's GZIP content encoding
filter [1] instead of GFs to see if similar intermittent problems occur. That
might help isolate the issue.

It might be that the GZIP Grizzly support is prematurely reseting or finishing
the deflator.

Paul.

[1] http://jersey.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/container/filter/GZIPContentEncodingFilter.html



On Dec 7, 2010, at 3:38 PM, Ronak Patel wrote:

Hi all,
>
>
>Has anyone ever tried to gzip compress the json being generated by JAX-RS Jersey
>through Glassfish V3?
>
>
>I'm seeing intermittent stack traces like these:
>
>
>Caused by: org.apache.catalina.connector.ClientAbortException:
>java.io.IOException: write beyond end of stream
> at
>org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:425)
> at com.sun.grizzly.util.buf.ByteChunk.flushBuffer(ByteChunk.java:433)
> at
>org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:373)
> at
>org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:351)
> at
>org.apache.catalina.connector.CoyoteOutputStream.flush(CoyoteOutputStream.java:176)
>
> at
>com.sun.jersey.spi.container.servlet.WebComponent$Writer.flush(WebComponent.java:318)
>
> at
>com.sun.jersey.spi.container.ContainerResponse$CommittingOutputStream.flush(ContainerResponse.java:145)
>
> at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:278)
> at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:122)
> at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:212)
> at
>org.codehaus.jackson.impl.WriterBasedGenerator.flush(WriterBasedGenerator.java:640)
>
> at
>com.sun.jersey.json.impl.writer.JacksonRootStrippingGenerator.flush(JacksonRootStrippingGenerator.java:236)
>
> at
>com.sun.jersey.json.impl.writer.JacksonStringMergingGenerator.flush(JacksonStringMergingGenerator.java:240)
>
> at
>com.sun.jersey.json.impl.writer.Stax2JacksonWriter.flush(Stax2JacksonWriter.java:350)
>
> ... 51 more
>Caused by: java.io.IOException: write beyond end of stream
> at
>java.util.zip.DeflaterOutputStream.write(DeflaterOutputStream.java:104)
> at java.util.zip.GZIPOutputStream.write(GZIPOutputStream.java:72)
> at
>com.sun.grizzly.tcp.http11.filters.GzipOutputFilter.doWrite(GzipOutputFilter.java:125)
>
> at
>com.sun.grizzly.tcp.http11.InternalOutputBuffer.doWrite(InternalOutputBuffer.java:640)
>
> at com.sun.grizzly.tcp.Response.doWrite(Response.java:676)
> at
>org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:420)
> ... 64 more
>
>
>Does anyone have any suggestions to try?
>
>
>Ronak Patel
>
>