Apache Camel 的 JsonMappingException [英] JsonMappingException with Apache Camel

查看:39
本文介绍了Apache Camel 的 JsonMappingException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了骆驼路线的异常

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)

骆驼路线:

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

推荐答案

在将正文编组为 json 之前将其转换为字符串.您可以在元帅之前添加 .convertBodyTo(String.class) .问题是您正在发送一个流,而 jackson 不知道如何对其进行序列化.

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.

这篇关于Apache Camel 的 JsonMappingException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆