users@jersey.java.net

[Jersey] Re: Return a response with JSON entity and status code 400 turned into HTML body

From: Rindt, Daniel <drindt_at_viselabs.com>
Date: Mon, 26 Jan 2015 10:44:16 +0100

2015-01-21 12:22 GMT+01:00 Libor Kramolis <libor.kramolis_at_oracle.com>:
> Hi Daniel.

Dear Libor,

> To be honest I don’t know which use case does not work for you. Are you
> trying to invoke the use case ending with "201 Created” or "400 Bad
> Request”? I guess you are trying to get 201 but get 400. And I expect you
> already tracked via ContainerResponseFilter that your resource method
> already returned 201 response. Right?

Yes.

> GAE has some classes on black list. May be it is that case. But more
> information is needed. May you set more verbose logging of Jersey? I have
> found out short blog post about logging configuration:
> http://www.mkyong.com/google-app-engine/configure-logging-in-google-app-engine/.
> Or may you create simplified GAE project shared on Gist for example to
> reproduce the problem?

Here you can take a look into the class:
https://gist.github.com/drindt/a678b9827d7956910c17

The method return in all cases a Response object. But with different
entities set in
case of an error. Also the methods to return the errors you can shown here:
https://gist.github.com/drindt/2aae6e4294a1002fc5e0

The implementation is right now a quick & dirty approach and should
more considered
as experimental.

First i was thinking this is appengine related so i build quick and
dirty a servlet extending
class which sets directly the response codes like 40x also i wrote in
the stream a json string.
The result was properly shown from my curl requests. But with the code
from the gists
i got html responses.

I am really out of ideas whats going there. So any help is really welcome.

Thank you a lot for reading and support.
Daniel