users@jersey.java.net

[Jersey] JSON serialization question

From: Laird Nelson <ljnelson_at_gmail.com>
Date: Fri, 16 Jan 2015 20:57:31 -0800

Section 4.3 of the JAX-RS 2.0 specification reads (in part):

4.3. Auto-Discoverable Features

[...] For a few Jersey provided modules however there is no need to
explicitly register their extension Features as these are discovered and
registered in the Configuration
<http://jax-rs-spec.java.net/nonav/2.0/apidocs/javax/ws/rs/core/Configuration.html>
(on
client/server) automatically by Jersey runtime whenever the modules
implementing these features are present on the classpath of the deployed
JAX-RS application. The modules that are automatically discovered include:
JSON binding feature from jersey-media-moxy
jersey-media-json-processing


I have a war file that does not supply any JSON serialization classes or
libraries of its own (no Jackson, no Moxy, no MessageBodyWriters, etc.).
Some of my resource classes served up by that application serve entities,
in turn, of media type application/json. Ordinary stuff.

My war file contains no servlet information—just an Application subclass
that does not override any methods—and is not tied to Jersey in any way,
just to a JAX-RS runtime.

I am getting a 500 error from Jersey v2.10 as shipped with Glassfish 4.1
(and the error is hidden—but that's another story) that indicates that
there is no MessageBodyWriter that can serialize my entity. Isn't Moxy, at
least, present by default in the Glassfish classpath (see
modules/jersey-media-moxy.jar, though I'm not too familiar with exactly how
those modules are added to the classpath)?

My interpretation of the above section is that in Glassfish 4.1 Moxy at
least should be active and attempting to serialize my entity. Is that
correct? If so, I'll try to put together a test case.

(Disclaimer in case it matters in some way: I work for Oracle, but not on
Jersey or JAX-RS.)

Best,
Laird

-- 
http://about.me/lairdnelson