Thsi is my code:
@GET
@Path("getBeanAsObject")
@Produces(MediaType.APPLICATION_JSON)
public TestBean sayHtmlHelloBeanObject() {
TestBean tb = new TestBean();
tb.setName("My name");
return tb;
}
And the TestBean.java is:
@XmlRootElement
public class TestBean implements Serializable {
private String name;
public TestBean() {
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return name;
}
}
I get the following exception:
2012-02-17 09:14:27,437 [http-8080-2] ERROR container.ContainerResponse - A
message body writer for Java class com.test.TestBean, and Java type class
com.test.TestBean, and MIME media type application/json was not found
2012-02-17 09:14:27,437 [http-8080-2] ERROR container.ContainerResponse -
The registered message body writers compatible with the MIME media type are:
*/* ->
com.sun.jersey.core.impl.provider.entity.FormProvider
com.sun.jersey.core.impl.provider.entity.StringProvider
com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
com.sun.jersey.core.impl.provider.entity.FileProvider
com.sun.jersey.core.impl.provider.entity.InputStreamProvider
com.sun.jersey.core.impl.provider.entity.DataSourceProvider
com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General
com.sun.jersey.core.impl.provider.entity.ReaderProvider
com.sun.jersey.core.impl.provider.entity.DocumentProvider
com.sun.jersey.core.impl.provider.entity.StreamingOutputProvider
com.sun.jersey.core.impl.provider.entity.SourceProvider$SourceWriter
com.sun.jersey.server.impl.template.ViewableMessageBodyWriter
com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General
com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General
Any help appreciated, thanks in advance.
--
View this message in context: http://jersey.576304.n2.nabble.com/Error-producing-Json-object-urgent-help-required-tp7293119p7293119.html
Sent from the Jersey mailing list archive at Nabble.com.