JsonMappingException with Apache Camel

主宰稳场 提交于 2020-07-09 05:37:51

问题


I am getting below exception with Camel Route

Caused by: com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.apache.camel.converter.stream.InputStreamCache and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)
    at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:284)
    at com.fasterxml.jackson.databind.SerializerProvider.mappingException(SerializerProvider.java:1110)
    at com.fasterxml.jackson.databind.SerializerProvider.reportMappingProblem(SerializerProvider.java:1135)
    at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:69)
    at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:32)
    at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:292)
    at com.fasterxml.jackson.databind.ObjectWriter$Prefetch.serialize(ObjectWriter.java:1429)
    at com.fasterxml.jackson.databind.ObjectWriter._configAndWriteValue(ObjectWriter.java:1158)

Camel Route:

restConfiguration().producerComponent("http4").host("localhost").port(9080);


    from("direct:getSubscriptions")
        .hystrix()
        .to("rest:get:testendpoint?carrier={carrier}&flightNumber={flightNumber}&origin={origin}&destination={destination}&date={date}")
        .log(">> - ${body}")
        .marshal().json(JsonLibrary.Jackson)
        .split().jsonpathWriteAsString("$.[1]", true)
        .log("${body}");

Not sure I am doing it correct? Any suggestions will be appreciated


回答1:


Convert your body to string before marshaling it to json. You can add .convertBodyTo(String.class) before your marshal. The issue is that you are sending a stream and jackson doesn't know how to serialize it.



来源:https://stackoverflow.com/questions/48798907/jsonmappingexception-with-apache-camel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!