Marshalling JSON to JAXB annotated POJO returns "null" in RESTEasy client on EAP
Issue
- We are experiencing a content marshalling issue with EAP 6 when marshalling JSON to JAXB annotated POJO.
- According to the RESTEasy documentation, "RESTEasy allows you to marshall JAXB annotated POJOs to and from JSON. This provider wraps the Jettison JSON library to accomplish this." But it is not working in my case.
- Below is the actual POJO class (note that we added
@JsonIgnoreProperties(ignoreUnknown = true)annotation):
@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement(name="return")
public class MyResponse {
private List<Post> posts;
@XmlElementWrapper(name = "messages")
@XmlElement(name = "message")
public List<Post> getPosts() { return posts; }
public void setPosts(List<Post> posts) { this.posts = posts; }
}
- And the JSON string I am receiving after posting a message:
{
"should_be_ignored": {},
"messages": [
{ ... }
],
...
}
- Here is the RESTEasy client code running on EAP:
import org.jboss.resteasy.client.ClientRequest;
import org.jboss.resteasy.client.ClientResponse;
ClientRequest clientRequest = new ClientRequest("https://...");
ClientResponse<MyResponse> response = clientRequest.get(MyResponse.class);
MyResponse myResponse = response.getEntity();
- However, all the time the
"posts"field inMyResponseis bound tonullwhen marshalling the received JSON to POJO.
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 5.x
- 6.x
- RESTEasy
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
