Ingo D Ingo D - 1 year ago 174
reST (reStructuredText) Question

Unmarshaling JSON with Apache Camel

I use the Apache Camel component http4 to request data from a REST web service.

The response type of this REST service is JSON.


I have a JSON annotated Java Class which reflects the JSON structure


public class Report {

private Coord coord;
private List<Weather> weather = new ArrayList<Weather>();
private String base;


Within the Camel Route I defined a JsonDataFormat which is referring to the annotated class.

public void configure() throws Exception {
JsonDataFormat jsonDataFormat = new JsonDataFormat();


this results in an Exception:

com.thoughtworks.xstream.mapper.CannotResolveClassException: coord at

  • I tried to use the class Coord as unmarshalType

  • I used the fully qualified name for the unmarshalType

  • I also tried a pure Pojo without JSON-Annotations

Answer Source

Can you try specifying Jackson as the JsonLibrary of your data format? The annotations you use are Jackson's yet XStream tries to perform the unmarshal:

JsonDataFormat jsonDataFormat = new JsonDataFormat(JsonLibrary.Jackson);

From everyhting I've seen this should work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download