users@jersey.java.net

[Jersey] Re: Jersey 1.17 - JerseyTest vs Json

From: Michal Gajdos <michal.gajdos_at_oracle.com>
Date: Wed, 12 Jun 2013 10:04:41 +0200

Hi,

you cannot return a simple boolean value from a resource method if you
want it to be serialized into Json (this wouldn't produce a valid Json).
You need to return a JAXB bean from your method, like:

@XmlRootElement
public class TestBean {

    private boolean value;

    // create getters and setters
}

To learn more about the Json support in Jersey, see:
https://jersey.java.net/nonav/documentation/1.17/json.html

Michal

On 12.06.2013 09:24 , pub cog wrote:
> Hi,
> I'm trying to use JerseyTest (v1.17) as describe here:
> https://jersey.java.net/nonav/documentation/1.17/test-framework.html
> But I keep getting this error:
>
> A message body writer for Java class java.lang.Boolean, and Java type
> class java.lang.Boolean, and MIME media type application/json was not
> found
>
> I made a simple and basic sample projet to reproduce this issue here:
> https://github.com/francisoud/jersey
> Could you take a look at it please.
> I must be missing something obvious ?!
> Thanks in advance