users@jersey.java.net

[Jersey] Re: Debugging Moxy Feature

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Wed, 2 Apr 2014 13:29:45 +0200

First thing I would try is to enable VERBOSE request processing tracing in Jersey and send a few requests to get the idea about what's going on.

Then, when debugging, I would typically set breakpoints on the main locations where request flows:

- in the container service method:
https://github.com/jersey/jersey/blob/master/containers/grizzly2-http/src/main/java/org/glassfish/jersey/grizzly2/httpserver/GrizzlyHttpContainer.java#L344
- in the container's response writer methods:
https://github.com/jersey/jersey/blob/master/containers/grizzly2-http/src/main/java/org/glassfish/jersey/grizzly2/httpserver/GrizzlyHttpContainer.java#L255
https://github.com/jersey/jersey/blob/master/containers/grizzly2-http/src/main/java/org/glassfish/jersey/grizzly2/httpserver/GrizzlyHttpContainer.java#L280
- in Jersey ServerRuntime.process method:
https://github.com/jersey/jersey/blob/master/containers/grizzly2-http/src/main/java/org/glassfish/jersey/grizzly2/httpserver/GrizzlyHttpContainer.java#L280
- in Jersey ServerRuntime.Responder.process methods:
https://github.com/jersey/jersey/blob/master/core-server/src/main/java/org/glassfish/jersey/server/ServerRuntime.java#L383
https://github.com/jersey/jersey/blob/master/core-server/src/main/java/org/glassfish/jersey/server/ServerRuntime.java#L420
- in your application resource method

The above will give you the general idea about what is happening and should also cover main request processing entry points as well as any thrown exceptions. It is a good starting debug setup when trying to isolate any request processing problems.

Marek

On 01 Apr 2014, at 20:48, Pascal Klink <pascal.klink_at_web.de> wrote:

> Hi everyone,
>
> I'm currently trying to enable the Moxy JSON Provider for my Jersey REST-Endpoints. So first some words to my setup I want to make Moxy work in:
>
> I'm running a Grizzly HttpServer to which I register HttpHandlers with Jersey. I'm creating the Handlers from Application instances in which I provide the instantiated endpoints as Singeltons. I'm doing this because I'm running in an OSGI environment where I publish my endpoints as Services to the Server which runs as a seperate bundle.
>
> So what I've done until now is including the jersey-media-moxy dependency in my bundle (as explained in the tutorial). Because I was not sure that jersey would correctly recognize the Moxy features in the OSGi environment (I'm everything else than an expert when it comes to classloading behaviour in OSGI environments) I debugged the creation of the HttpHandler and it seems that Jersey correctly loads the feature. At least instances of "org.glassfish.jersey.moxy.json.MoxyJsonFeature" and "org.glassfish.jersey.moxy.json.internal.ConfigurableMoxyJsonProvider" are contained in the runtimeConfig of the GrizzlyHttpContainer.
>
> The problem is that when I try to load data from a database using my REST service, a 500 Status Code is returned. But there is no Error Message in the Response of Grizzly and I could not find any log entries in the OSGI log. So I tried to debug the handling of the Request but with all those Threads created with inner Classes being run, it's not that easy. And in the Classes mentioned above I cannot find any method which seems to do the processing.
>
> So could anybody tell me where I have to start debugging in order to see the (un)marshalling of the Request/Response content done by Moxy? I think from there I would be able to solve the problem myself.
>
> Greetings,
> Pascal