Hi,
I am using spring cloud feign. I invoke an end point that returns String. I have configured jacksondecoder in my feign interface. I see that the end point is being successfully hit and it returns String value. However, the decoder fails to decode with the following exception. Can some one please help?
Exception in thread "main" com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'test': was expecting 'null', 'true', 'false' or NaN at [Source: (StringReader); line: 1, column: 9] at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1804) at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:703) at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._reportInvalidToken(ReaderBasedJsonParser.java:2853) at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._reportInvalidToken(ReaderBasedJsonParser.java:2831) at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._matchToken2(ReaderBasedJsonParser.java:2628) at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._matchToken(ReaderBasedJsonParser.java:2606) at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._matchTrue(ReaderBasedJsonParser.java:2564) at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:725) at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:4141) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4000) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3063) at com.feign.orch.Test.main(Test.java:16)
I am using the feign client to connect to rest easy end points hosted in jboss. I have configured my feign in a separate class as shown below
`public class JAXRSFeignConfig {
public JAXRSFeignConfig() {
}
@Bean
@DependsOn("objectMapper")
public Decoder feignDecoder(ObjectMapper objectMapper) {
return new JacksonDecoder(objectMapper);
}
@Bean
@DependsOn("objectMapper")
public Encoder feignEncoder(ObjectMapper objectMapper) {
return new JacksonEncoder(objectMapper);
}
@Bean
public Contract feignContract() {
return new JAXRSContract();
}
@Bean
public ObjectMapper objectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.findAndRegisterModules();
objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
return objectMapper;
}
}`
Comment From: OlgaMaciaszek
Hello @mazkozi please provide a minimal, complete, verifiable example that reproduces the issue.
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.