users@jersey.java.net

[Jersey] Re: JSON serialization question

From: Laird Nelson <ljnelson_at_gmail.com>
Date: Thu, 22 Jan 2015 18:33:43 -0800

On Fri, Jan 16, 2015 at 9:44 PM, Phillip Ross <phillip.w.g.ross_at_gmail.com>
wrote:

> I don't think the problem that I bumped into being an issue related to
> JPA entities specifically, but it was basically the bidirectionally
> and Moxy, being a JAXB implementation, needed some JAXB annotations to
> handle the bidirectionality.
>

Turns out this is at least tangentially related to what I'm observing.

I had an interface, implemented by an abstract class, which was then
extended by a concrete class (the thing being serialized). There's no
bidirectionality or anything at all complicated going on here; it would be
like:

public interface Animal {}

public abstract class AbstractAnimal implements Animal {}

public class Cat extends AbstractAnimal {}


Everything was serializing fine once upon a time. Then I did this:

public interface Legs {}

public interface Eyes {} // I'm no good at examples :-)

public interface Animal extends Legs, Eyes {}


...and deep in the bowels of Moxy a JAXBException is thrown, saying,
effectively:

The java interface Animal can not be mapped by JAXB as it has multiple
mappable parent interfaces. Multiple inheritence [sic] is not supported.


This exception is then swallowed—maybe deliberately; haven't figured that
out yet (debugging this is difficult, because the version of Moxy that
Jersey's Moxy JSON feature says it requires in Jersey 2.10.4 (the version
shipped with Glassfish 4.1) is 2.5.0, but it would appear from looking at
the actual module manifest in Glassfish that version 2.5.2 is used, so the
sources don't line up properly in the Netbeans debugger). At any rate, now
I think I've got something to go on.

Best,
Laird

-- 
http://about.me/lairdnelson