users@glassfish.java.net

JSON Compression from JAX-RS in Glassfish

From: Ronak Patel <ronak2121_at_yahoo.com>
Date: Tue, 7 Dec 2010 06:38:52 -0800 (PST)

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