Jersey Client message body reader for Java type not found

detri

New Member
I'm using Jersey 1.1 (old, I know - have to because I'm stuck with Java 1.5). I'm doing a simple GET where a Java object is returned as the entity. The Java object is being marshalled correctly (Java to XML) because I can make the GET request via the web and it works great. I'm trying to use the Jersey client to make the GET request and unmarshall it back to the Java object and this is where it's failing. Shouldn't Jersey know how to unmarshall the XML it receives from the GET request back into the POJO since it's annotated correctly? It works on the server side. Here's the exception I get:\[code\]ClientHandlerException: A message body reader for Java type, class my.class.SearchResult, and MIME media type, application/xml was not found.\[/code\]Here's the client code:\[code\]private SearchResult search() { WebResource wr = new Client().resource( "http://localhost:8080/MyProject/search" ); return wr.get( SearchResult.class );}\[/code\]Here's the JAXB annotated POJO I'm using on the client and server:\[code\]@XmlRootElement(name = "searchResults")@XmlAccessorType(XmlAccessType.FIELD)@XmlType(name = "searchResults", propOrder = { "results"})public class SearchResult { @XmlElement(name = "result") private List<Result> results = new ArrayList<Result>(); public List<Result> getResults() { return results; } ...}\[/code\]Here's the inner Result POJO as well:\[code\]@XmlAccessorType(XmlAccessType.FIELD)@XmlType(name = "resultType", propOrder = { "name", "version", "type"})public class Result { private String name; private String version; private String type; ...}\[/code\]Here's the GET service itself:\[code\]@Path("/search")public class SearchRest { @GET @Produces(MediaType.APPLICATION_XML) public SearchResult search() { SearchResult result = new SearchResult(); .... return result; }}\[/code\]Thank you!
 
Back
Top