Camel REST: jackson.databind.JsonMappingException: Infinite recursion (StackOverflowError)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Camel REST: jackson.databind.JsonMappingException: Infinite recursion (StackOverflowError)

Martin Lichtin-2
I'm running into a jackson.databind.JsonMappingException: Infinite recursion (StackOverflowError)
with a REST route that uses bindingMode="json" to marshal/unmarshal. It loops like:

     ...
     at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:689)
     at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:155)
     at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeFields(MapSerializer.java:633)
     at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:536)
     at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:30)
     at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:704)
     at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:689)
     at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:155)
     ...
     (not seeing full stack unfortunately)

What's strange is that outside of Camel, I can use a Jackson ObjectWriter just fine to serialize the same object.

So - wanted to ask for pointers where and how Camel (2.18.5) creates and configures its ObjectWriter
that is used in RestConsumerBindingMarshalOnCompletion?

- Martin

Reply | Threaded
Open this post in threaded view
|

Re: Camel REST: jackson.databind.JsonMappingException: Infinite recursion (StackOverflowError)

Martin Lichtin-2
To make REST use my own ObjectMapper, I try below but it doesn't work.
Anyone have an example that does?

   <bean id="objectMapper" class="my.ObjectMapper">
   </bean>

   <camelContext id="rest" xmlns="http://camel.apache.org/schema/blueprint">

     <dataFormats>
       <json id="json" library="Jackson" objectMapper="objectMapper" />
     </dataFormats>

     <restConfiguration component="servlet" bindingMode="json" >
     ....

Thanks for a hint.

On 01.11.2017 22:21, Martin Lichtin wrote:

> I'm running into a jackson.databind.JsonMappingException: Infinite recursion (StackOverflowError)
> with a REST route that uses bindingMode="json" to marshal/unmarshal. It loops like:
>
>     ...
>     at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:689)
>     at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:155)
>     at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeFields(MapSerializer.java:633)
>     at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:536)
>     at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:30)
>     at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:704)
>     at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:689)
>     at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:155)
>     ...
>     (not seeing full stack unfortunately)
>
> What's strange is that outside of Camel, I can use a Jackson ObjectWriter just fine to serialize the same object.
>
> So - wanted to ask for pointers where and how Camel (2.18.5) creates and configures its ObjectWriter
> that is used in RestConsumerBindingMarshalOnCompletion?
>
> - Martin