users@jersey.java.net

[Jersey] Re: returning default jersey responses as json

From: Bobby Bissett <bbissett_at_gmail.com>
Date: Wed, 18 Nov 2015 16:38:02 -0500

On Wed, Nov 18, 2015 at 4:15 PM, Alperovitch, Yasmine <
Yasmine.Alperovitch_at_emc.com> wrote:

> What server are you using?
>
> I think it might not be jersey that handles these things but rather the
> server.
>

Using GlassFish 3.1.2.2. The URLs I'm trying to handle with json are
definitely mapped to com.sun.jersey.spi.container.servlet.ServletContainer,
so I know it's involved there somewhere, but I suspect Jersey just passes
the status code and details off to the servlet container to generate the
actual html.

Cheers,
Bobby



> I found this for jetty (not sure what you’re using):
>
> https://wiki.eclipse.org/Jetty/Howto/Custom_Error_Pages
>
>
>
> Thanks,
>
> Jasmine
>
>
>
> *From:* Bobby Bissett [mailto:bbissett_at_gmail.com]
> *Sent:* Wednesday, November 18, 2015 3:59 PM
> *To:* users_at_jersey.java.net
> *Subject:* [Jersey] Re: returning default jersey responses as json
>
>
>
> On Wed, Nov 18, 2015 at 2:41 PM, Jennifer Sears <jsears_at_galtech.net>
> wrote:
>
> Have you tried using a custom ObjectMapper? It sounds like you need to
> map your exceptions like described at the link below.
>
>
>
> Thanks for the quick response. My exceptions (meaning anything I throw or
> catch) are all ok since I can throw a custom Exception that can generate
> the JSON. It's the cases where my code isn't even called that I don't know
> how to handle.
>
> For instance, when someone hits http://myserver/this_is_not_a_real_url I
> don't know if Jersey generates an exception internally or if it just sees
> that the URI doesn't match anything and responds with the 404. If so, then
> maybe the mapping would work. I'll try that and just map to Exception to
> see if something useful pops out.
>
> Cheers,
>
> Bobby
>
>
>
>
>