Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-9022

JacksonTypeConverter breaks CSV marshalling

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.16.0
    • Component/s: None
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      Marshalling a Map to CSV internally converts a Map to a List. It seems that the JacksonTypeConverters now claim to be able to this. It however fails with

      Caused by: org.apache.camel.TypeConversionException: Error during type conversion from type: java.lang.String to the required type: java.util.List with value {firstName=John, lastName=Doe} due java.lang.IllegalArgumentException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token
       at [Source: N/A; line: -1, column: -1]
      	at org.apache.camel.impl.converter.BaseTypeConverterRegistry.createTypeConversionException(BaseTypeConverterRegistry.java:585)
      	at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:131)
      	at org.apache.camel.util.ExchangeHelper.convertToType(ExchangeHelper.java:203)
      	at org.apache.camel.dataformat.csv.CsvMarshaller.marshal(CsvMarshaller.java:77)
      	at org.apache.camel.dataformat.csv.CsvDataFormat.marshal(CsvDataFormat.java:78)
      	at org.apache.camel.processor.MarshalProcessor.process(MarshalProcessor.java:83)
      	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
      	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:454)
      	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
      	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
      	at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)
      	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
      	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
      	at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:68)
      	at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:404)
      	at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:372)
      	at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:262)
      	at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:372)
      	at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:230)
      	at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:128)
      	at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:132)
      	... 147 more
      Caused by: org.apache.camel.RuntimeCamelException: java.lang.IllegalArgumentException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token
       at [Source: N/A; line: -1, column: -1]
      	at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1642)
      	at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1247)
      	at org.apache.camel.impl.converter.StaticMethodFallbackTypeConverter.convertTo(StaticMethodFallbackTypeConverter.java:62)
      	at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:327)
      	at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:114)
      	... 166 more
      Caused by: java.lang.IllegalArgumentException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token
       at [Source: N/A; line: -1, column: -1]
      	at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:3286)
      	at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:3212)
      	at org.apache.camel.component.jackson.converter.JacksonTypeConverters.convertTo(JacksonTypeConverters.java:44)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:483)
      	at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1243)
      	... 169 more
      Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token
       at [Source: UNKNOWN; line: -1, column: -1]
      	at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:148)
      	at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:835)
      	at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:831)
      	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.handleNonArray(CollectionDeserializer.java:283)
      	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:222)
      	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:212)
      	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:25)
      	at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:3281)
      	... 176 more
      

      CrossRef: https://github.com/wildfly-extras/wildfly-camel/issues/784

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                davsclaus Claus Ibsen
                Reporter:
                tdiesler Thomas Diesler
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: