I am trying to use Firefox poster to test a Jersey restful webservice running on Glassfish 4.0. I am getting a HTTP Server 500 error returned to the Poster output when I return a java class as xml. I do not get an error when I return a String as xml. This makes me wonder if I need to include any of the JAX-RS jars or Jersey jars in my ear on Glassfish. I was thinking these were included in the Glassfish modules so I am not including them in my WEB-INF lib.
Here is an example of what works, returns xml to firefox poster:
@GET
@Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, "application/x-javascript", MediaType.APPLICATION_OCTET_STREAM } )
@Path( "/getTest/" )
public String getXml()
{
return "<?xml version=\"1.0\"?>" + "<hello> Hello Jersey" + "</hello>";
}
Here is an example of what throws the Internal server error 500:
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path( "/getTodo/" )
public Todo getXML() {
Todo todo = new Todo();
todo.setSummary("This is my first todo");
todo.setDescription("This is my first todo");
return todo;
}
@XmlRootElement
// JAX-RS supports an automatic mapping from JAXB annotated class to XML and JSON
// Isn't that cool?
public class Todo {
private String summary;
private String description;
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
FYI - I am loosely following the blog here - restBlog