users@jersey.java.net

[Jersey] Re: Empty response body on Error

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Sun, 18 May 2014 22:29:17 -0700

Hi Robert,

it's not just a Grizzly issue, the problem is that when error happens
(at least 404 error) - Jersey calls
ContainerResponseWriter:writeResponseStatusAndHeaders method:

         @Override
         public OutputStream writeResponseStatusAndHeaders(final long
contentLength,
                                                           final
ContainerResponse context)
                 throws ContainerException;

passing 404 status and content-length==0.
So, GrizzlyContainer just does what it is asked - flushes the 404
response with 0 content length. I've just checked - Jetty container does
the same.
I'd suggest you to file a Jersey issue and let Jersey team comment on it.

Thanks.

WBR,
Alexey.

On 17.05.14 13:00, Robert DiFalco wrote:
> 2.3.11 for Grizzly, 2.8 for Jersey.
>
> return
> GrizzlyHttpServerFactory.createHttpServer(
> URI.create( "http://0.0.0.0:8080/rest/" ),
> new JerseyResourceConfiguration());
>
>
> JerseyResourceConfiguration is pretty basic. Just setups up Json and
> my resource paths.
>
>
>
> On Sat, May 17, 2014 at 12:31 PM, Oleksiy Stashok
> <oleksiy.stashok_at_oracle.com <mailto:oleksiy.stashok_at_oracle.com>> wrote:
>
> Hi Robert,
>
> which Jersey/Grizzly versions are you using?
> Can you pls. share the server initialization code?
>
>
> Thanks.
>
> WBR,
> Alexey.
>
>
> On 17.05.14 10:33, Robert DiFalco wrote:
>
> I'm noticing with the Grizzly HTTP container (I can't speak
> for other containers) that when my REST call has an error,
> lets say a 404, on a GET that the response seems blank.
>
> If I curl with "-i" I can see the 404 but if I put it into a
> web browser or just omit the "-i" on curl I see nothing. So it
> has a response body it is just empty.
>
> Is this normal or is there something amiss in my configuration?
>
> Thanks!
>
>
>
>