camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CAMEL-11718) Setting camel.dataformat.json-jackson.object-mapper throws exception
Date Mon, 04 Sep 2017 07:00:14 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-11718?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16152185#comment-16152185
] 

Claus Ibsen edited comment on CAMEL-11718 at 9/4/17 7:00 AM:
-------------------------------------------------------------

Thanks, yeah we can look at improving this. 

Do you have a sample project you can share as a .zip file attached to this JIRA or put it
on github or something?


was (Author: davsclaus):
Thanks, yeah we can look at improving this

> Setting camel.dataformat.json-jackson.object-mapper throws exception
> --------------------------------------------------------------------
>
>                 Key: CAMEL-11718
>                 URL: https://issues.apache.org/jira/browse/CAMEL-11718
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-jackson
>    Affects Versions: 2.19.2
>            Reporter: Roman
>
> I wanted to reuse the Jackson object mapper used by Spring MVC but jackson json configuration
via YML is not working an causing an exception
> {code:none}
> camel:
>   springboot:
>     name: ${spring.application.name}
>   dataformat:
>     json-jackson:
>       object-mapper: jacksonObjectMapper
> spring:
>   jackson:
>     property-naming-strategy: com.fasterxml.jackson.databind.PropertyNamingStrategy.SnakeCaseStrategy
>     default-property-inclusion: non_null
>     serialization:
>       WRITE_DATES_AS_TIMESTAMPS: true
> {code}
> Throws the following exception:
> {noformat}
> org.apache.camel.spring.boot.CamelSpringBootInitializationException: org.apache.camel.FailedToCreateRouteException:
Failed to create route test-public: Route(test-public)[[From[rest:get:/test?routeId=test-public&...
because of java.lang.IllegalArgumentException: Could not find a suitable setter for property:
objectMapper as there isn't a setter method with same type: java.lang.String nor type conversion
possible: No type converter available to convert from type: java.lang.String to the required
type: com.fasterxml.jackson.databind.ObjectMapper with value jacksonObjectMapper
> 	at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:225)
> 	at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:52)
> 	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)
> 	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
> 	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)
> 	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)
> 	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883)
> 	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144)
> 	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
> 	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
> 	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
> 	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
> 	at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
> 	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
> 	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
> 	at au.com.iag.payments.service.OnlinePaymentsApplicationKt.main(OnlinePaymentsApplication.kt:15)
> Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route test-public:
Route(test-public)[[From[rest:get:/test?routeId=test-public&... because of java.lang.IllegalArgumentException:
Could not find a suitable setter for property: objectMapper as there isn't a setter method
with same type: java.lang.String nor type conversion possible: No type converter available
to convert from type: java.lang.String to the required type: com.fasterxml.jackson.databind.ObjectMapper
with value jacksonObjectMapper
> 	at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:209)
> 	at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:1087)
> 	at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3540)
> 	at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3271)
> 	at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:202)
> 	at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3089)
> 	at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3085)
> 	at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:3108)
> 	at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:3085)
> 	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
> 	at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:3022)
> 	at org.apache.camel.spring.boot.RoutesCollector.maybeStart(RoutesCollector.java:242)
> 	at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:217)
> 	... 15 common frames omitted
> Caused by: org.apache.camel.RuntimeCamelException: java.lang.IllegalArgumentException:
Could not find a suitable setter for property: objectMapper as there isn't a setter method
with same type: java.lang.String nor type conversion possible: No type converter available
to convert from type: java.lang.String to the required type: com.fasterxml.jackson.databind.ObjectMapper
with value jacksonObjectMapper
> 	at org.apache.camel.component.jackson.springboot.JacksonDataFormatAutoConfiguration$1.newInstance(JacksonDataFormatAutoConfiguration.java:80)
> 	at org.apache.camel.impl.DefaultDataFormatResolver.createDataFormat(DefaultDataFormatResolver.java:58)
> 	at org.apache.camel.impl.DefaultDataFormatResolver.resolveDataFormat(DefaultDataFormatResolver.java:45)
> 	at org.apache.camel.impl.DefaultCamelContext.resolveDataFormat(DefaultCamelContext.java:4240)
> 	at org.apache.camel.model.rest.RestBindingDefinition.createRestBindingAdvice(RestBindingDefinition.java:122)
> 	at org.apache.camel.impl.DefaultRouteContext.commit(DefaultRouteContext.java:201)
> 	at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1302)
> 	at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:204)
> 	... 27 common frames omitted
> Caused by: java.lang.IllegalArgumentException: Could not find a suitable setter for property:
objectMapper as there isn't a setter method with same type: java.lang.String nor type conversion
possible: No type converter available to convert from type: java.lang.String to the required
type: com.fasterxml.jackson.databind.ObjectMapper with value jacksonObjectMapper
> 	at org.apache.camel.util.IntrospectionSupport.setProperty(IntrospectionSupport.java:614)
> 	at org.apache.camel.util.IntrospectionSupport.setProperty(IntrospectionSupport.java:640)
> 	at org.apache.camel.util.IntrospectionSupport.setProperties(IntrospectionSupport.java:497)
> 	at org.apache.camel.component.jackson.springboot.JacksonDataFormatAutoConfiguration$1.newInstance(JacksonDataFormatAutoConfiguration.java:76)
> 	... 34 common frames omitted
> {noformat}
> I have also tried with
> {code}
>       ...
>       object-mapper: "#jacksonObjectMapper"
>       ...
> {code}
> to give the property introspection logic a hint that it is a ref, but result is the same.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message