Jersey boolean how return value how?

I had a big problem using a REST installation. Returning complex types works fine, but I cannot return primitive types:

@GET
@Path("/testbool")
@Produces(MediaType.APPLICATION_XML)
public Boolean testbool(){
    return false;
}

@GET
@Path("/testbool")
@Produces(MediaType.APPLICATION_XML)
public boolean testbool(){
    return false;
}

does not work because I get an exception:

Called: com.sun.jersey.api.MessageException: message body writer for Java class java.lang.Boolean and Java class class java.lang.Boolean and media type / xml MIME application were not found

Is there an easy way to fix this? - I already went to Google for this, but I could not find a simple solution without writing a wrapper or creating a blacksmith myself. But I can’t imagine that such a simple thing is not included.

thank you for your help!

+4

All Articles