org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [@org.springframework.web.bind.annotation.RequestParam @org.springframework.format.annotation.DateTimeFormat java.time.LocalDate] for value '7/11/16'; nested exception is java.time.format.DateTimeParseException: Text '7/11/16' could not be parsed at index 0","path":"/tomorrow"}

GitHub | fabmars | 5 months ago
  1. 0

    Feign client doesn't serialize java.time.LocalDate's correctly

    GitHub | 5 months ago | fabmars
    org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [@org.springframework.web.bind.annotation.RequestParam @org.springframework.format.annotation.DateTimeFormat java.time.LocalDate] for value '7/11/16'; nested exception is java.time.format.DateTimeParseException: Text '7/11/16' could not be parsed at index 0","path":"/tomorrow"}
  2. 0

    First things first, I'm not sure it's the right place to log this issue. It may be @Netflix/feign. Please advise. It is no longer possible to use a Feign client accepting a java.time.LocalDate as a method param where it is supposed to comply with a given format like @DateTimeFormat(iso = ISO.DATE). If you do, you get a *java.time.format.DateTimeParseException: Text '7/11/16' could not be parsed at index 0"*, where it's clear the serialization format is NOT the requested ISO-8601 uuuu-MM-dd but M/d/uu. I put the whole stacktrace below. I made a stripped project to reproduce the issue: https://github.com/fabmars/feign-localdate-bug Just import, run ApplicationServer, ApplicationClient, they are supposed to query a local eureka server, and hit http://localhost:8080/bug It's worth noticing that LocalDate's used to be serialized correctly back in spring-cloud-netflix:1.0.7, you may even try it in my example project. So there is a strong suspiscion there is a regression since spring-cloud-netflix:1.1.0 at least (before Brixton, even). {code} 2016-07-11 21:48:32.838 ERROR 9398 --- [nio-8080-exec-7] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.netflix.hystrix.exception.HystrixRuntimeException: getTomorrow failed and no fallback available.] with root cause feign.FeignException: status 400 reading TimeClient#getTomorrow(LocalDate,String); content: {"timestamp":1468266512745,"status":400,"error":"Bad Request","exception":"org.springframework.web.method.annotation.MethodArgumentTypeMismatchException","message":"Failed to convert value of type [java.lang.String] to required type [java.time.LocalDate]; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [@org.springframework.web.bind.annotation.RequestParam @org.springframework.format.annotation.DateTimeFormat java.time.LocalDate] for value '7/11/16'; nested exception is java.time.format.DateTimeParseException: Text '7/11/16' could not be parsed at index 0","path":"/tomorrow"} at feign.FeignException.errorStatus(FeignException.java:62) ~[feign-core-8.16.2.jar:8.16.2] at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:91) ~[feign-core-8.16.2.jar:8.16.2] at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:134) ~[feign-core-8.16.2.jar:8.16.2] at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:76) ~[feign-core-8.16.2.jar:8.16.2] at feign.hystrix.HystrixInvocationHandler$1.run(HystrixInvocationHandler.java:97) ~[feign-hystrix-8.16.2.jar:8.16.2] at com.netflix.hystrix.HystrixCommand$1.call(HystrixCommand.java:293) ~[hystrix-core-1.5.3.jar:1.5.3] at com.netflix.hystrix.HystrixCommand$1.call(HystrixCommand.java:289) ~[hystrix-core-1.5.3.jar:1.5.3] at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:46) ~[rxjava-1.1.5.jar:1.1.5] at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35) ~[rxjava-1.1.5.jar:1.1.5] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50) ~[rxjava-1.1.5.jar:1.1.5] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.1.5.jar:1.1.5] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50) ~[rxjava-1.1.5.jar:1.1.5] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.1.5.jar:1.1.5] at rx.Observable.unsafeSubscribe(Observable.java:8460) ~[rxjava-1.1.5.jar:1.1.5] at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:51) ~[rxjava-1.1.5.jar:1.1.5] at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35) ~[rxjava-1.1.5.jar:1.1.5] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50) ~[rxjava-1.1.5.jar:1.1.5] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.1.5.jar:1.1.5] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50) ~[rxjava-1.1.5.jar:1.1.5] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.1.5.jar:1.1.5] at rx.Observable.unsafeSubscribe(Observable.java:8460) ~[rxjava-1.1.5.jar:1.1.5] at rx.internal.operators.OperatorSubscribeOn$1.call(OperatorSubscribeOn.java:94) ~[rxjava-1.1.5.jar:1.1.5] at com.netflix.hystrix.strategy.concurrency.HystrixContexSchedulerAction$1.call(HystrixContexSchedulerAction.java:56) ~[hystrix-core-1.5.3.jar:1.5.3] at com.netflix.hystrix.strategy.concurrency.HystrixContexSchedulerAction$1.call(HystrixContexSchedulerAction.java:47) ~[hystrix-core-1.5.3.jar:1.5.3] at com.netflix.hystrix.strategy.concurrency.HystrixContexSchedulerAction.call(HystrixContexSchedulerAction.java:69) ~[hystrix-core-1.5.3.jar:1.5.3] at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55) ~[rxjava-1.1.5.jar:1.1.5] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_72] at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_72] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_72] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_72] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_72] {code}

    Spring JIRA | 5 months ago | Fabien MARSAUD
    org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [@org.springframework.web.bind.annotation.RequestParam @org.springframework.format.annotation.DateTimeFormat java.time.LocalDate] for value '7/11/16'; nested exception is java.time.format.DateTimeParseException: Text '7/11/16' could not be parsed at index 0","path":"/tomorrow"}
  3. 0

    If you define a repository this way: {code:java} @RepositoryRestResource(collectionResourceRel = "people", path = "people") public interface PersonRepository extends PagingAndSortingRepository<Person, Long> { Page<Person> findByAddress(@Param("address") Address address, Pageable p); } {code} where {{Address}} in another Entity, you can invoke the search method like this: http://localhost:8080/people/search/findByAddress?address=/addresses/1 and everything works like a charm. Now suppose you want to use QueryDSL predicates on the repository, so the repository must implement {{QueryDslPredicateExecutor}} interface: {code:java} @RepositoryRestResource(collectionResourceRel = "people", path = "people") public interface PersonRepository extends PagingAndSortingRepository<Person, Long>, QueryDslPredicateExecutor<Person> { Page<Person> findByAddress(@Param("address") Address address, Pageable p); } {code} By implementing this interface something changes in the REST behaviour of the repository and if you try to invoke the same search method: http://localhost:8080/people/search/findByAddress?address=/addresses/1 you get this exception: {noformat} org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type java.lang.Long for value '/addresses/1'; nested exception is java.lang.NumberFormatException: For input string: "/addresses/1" at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:41) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE] at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:192) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE] at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:176) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE] at org.springframework.data.repository.support.DomainClassConverter$ToEntityConverter.convert(DomainClassConverter.java:159) ~[spring-data-commons-1.11.1.RELEASE.jar:na] at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:35) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE] at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:192) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE] at org.springframework.data.querydsl.binding.QuerydslPredicateBuilder.convertToPropertyPathSpecificType(QuerydslPredicateBuilder.java:217) ~[spring-data-commons-1.11.1.RELEASE.jar:na] at org.springframework.data.querydsl.binding.QuerydslPredicateBuilder.getPredicate(QuerydslPredicateBuilder.java:109) ~[spring-data-commons-1.11.1.RELEASE.jar:na] at org.springframework.data.rest.webmvc.config.QuerydslAwareRootResourceInformationHandlerMethodArgumentResolver.postProcess(QuerydslAwareRootResourceInformationHandlerMethodArgumentResolver.java:88) ~[spring-data-rest-webmvc-2.4.1.RELEASE.jar:na] at org.springframework.data.rest.webmvc.config.RootResourceInformationHandlerMethodArgumentResolver.resolveArgument(RootResourceInformationHandlerMethodArgumentResolver.java:92) ~[spring-data-rest-webmvc-2.4.1.RELEASE.jar:na] at org.springframework.data.rest.webmvc.config.RootResourceInformationHandlerMethodArgumentResolver.resolveArgument(RootResourceInformationHandlerMethodArgumentResolver.java:40) ~[spring-data-rest-webmvc-2.4.1.RELEASE.jar:na] at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:78) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE] [...] Caused by: java.lang.NumberFormatException: For input string: "/addresses/1" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[na:1.8.0_66] at java.lang.Long.parseLong(Long.java:578) ~[na:1.8.0_66] at java.lang.Long.valueOf(Long.java:803) ~[na:1.8.0_66] at org.springframework.util.NumberUtils.parseNumber(NumberUtils.java:197) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE] at org.springframework.core.convert.support.StringToNumberConverterFactory$StringToNumber.convert(StringToNumberConverterFactory.java:61) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE] at org.springframework.core.convert.support.StringToNumberConverterFactory$StringToNumber.convert(StringToNumberConverterFactory.java:48) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE] at org.springframework.core.convert.support.GenericConversionService$ConverterFactoryAdapter.convert(GenericConversionService.java:425) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE] at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:35) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE] ... 60 common frames omitted {noformat} Trying to use the "previous" format (by passing the id of the related entity) http://localhost:8080/people/search/findByAddress?address=1 doesn't work either (this used to work with 2.2.3.RELEASE): {noformat} java.lang.IllegalArgumentException: Cannot resolve URI 1. Is it local or remote? Only local URIs are resolvable. at org.springframework.data.rest.core.UriToEntityConverter.convert(UriToEntityConverter.java:114) ~[spring-data-rest-core-2.4.1.RELEASE.jar:na] at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:35) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE] at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:192) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE] at org.springframework.data.repository.support.ReflectionRepositoryInvoker.convert(ReflectionRepositoryInvoker.java:248) ~[spring-data-commons-1.11.1.RELEASE.jar:na] at org.springframework.data.repository.support.ReflectionRepositoryInvoker.prepareParameters(ReflectionRepositoryInvoker.java:238) ~[spring-data-commons-1.11.1.RELEASE.jar:na] at org.springframework.data.repository.support.ReflectionRepositoryInvoker.invokeQueryMethod(ReflectionRepositoryInvoker.java:203) ~[spring-data-commons-1.11.1.RELEASE.jar:na] at org.springframework.data.rest.core.support.UnwrappingRepositoryInvokerFactory$UnwrappingRepositoryInvoker.invokeQueryMethod(UnwrappingRepositoryInvokerFactory.java:153) ~[spring-data-rest-core-2.4.1.RELEASE.jar:na] at org.springframework.data.querydsl.QuerydslRepositoryInvokerAdapter.invokeQueryMethod(QuerydslRepositoryInvokerAdapter.java:149) ~[spring-data-commons-1.11.1.RELEASE.jar:na] at org.springframework.data.rest.webmvc.RepositorySearchController.executeQueryMethod(RepositorySearchController.java:313) ~[spring-data-rest-webmvc-2.4.1.RELEASE.jar:na] at org.springframework.data.rest.webmvc.RepositorySearchController.executeSearch(RepositorySearchController.java:177) ~[spring-data-rest-webmvc-2.4.1.RELEASE.jar:na] {noformat}

    Spring JIRA | 1 year ago | Massimo Mangoni
    org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type java.lang.Long for value '/addresses/1'; nested exception is java.lang.NumberFormatException: For input string: "/addresses/1"
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    DynamicSpecifications 对时间类型的字符串的解析

    GitHub | 4 years ago | boliza
    org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type java.util.Date for value '2012-11-23 00:00:00'; nested exception is java.lang.IllegalArgumentException
  6. 0

    Normal {{String}} field tried to be converted to {{BigInteger}}. {code} org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type java.math.BigInteger for value 'KKaK'; nested exception is java.lang.NumberFormatException: For input string: "KKaK" at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:41) at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:170) at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:154) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.getPotentiallyConvertedSimpleWrite(MappingMongoConverter.java:604) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeSimpleInternal(MappingMongoConverter.java:585) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.access$100(MappingMongoConverter.java:73) at org.springframework.data.mongodb.core.convert.MappingMongoConverter$4.doWithPersistentProperty(MappingMongoConverter.java:370) at org.springframework.data.mongodb.core.convert.MappingMongoConverter$4.doWithPersistentProperty(MappingMongoConverter.java:357) at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:173) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeInternal(MappingMongoConverter.java:357) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeInternal(MappingMongoConverter.java:329) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.write(MappingMongoConverter.java:294) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.write(MappingMongoConverter.java:73) at org.springframework.data.mongodb.core.MongoTemplate.doInsert(MongoTemplate.java:615) at org.springframework.data.mongodb.core.MongoTemplate.insert(MongoTemplate.java:577) at org.springframework.data.mongodb.core.MongoTemplate.insert(MongoTemplate.java:568) {code}

    Spring JIRA | 5 years ago | drypot
    org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type java.math.BigInteger for value 'KKaK'; nested exception is java.lang.NumberFormatException: For input string: "KKaK"

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.springframework.core.convert.ConversionFailedException

      Failed to convert from type [java.lang.String] to type [@org.springframework.web.bind.annotation.RequestParam @org.springframework.format.annotation.DateTimeFormat java.time.LocalDate] for value '7/11/16'; nested exception is java.time.format.DateTimeParseException: Text '7/11/16' could not be parsed at index 0","path":"/tomorrow"}

      at feign.FeignException.errorStatus()
    2. feign-core
      SynchronousMethodHandler.invoke
      1. feign.FeignException.errorStatus(FeignException.java:62)[feign-core-8.16.2.jar:8.16.2]
      2. feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:91)[feign-core-8.16.2.jar:8.16.2]
      3. feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:134)[feign-core-8.16.2.jar:8.16.2]
      4. feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:76)[feign-core-8.16.2.jar:8.16.2]
      4 frames
    3. feign.hystrix
      HystrixInvocationHandler$1.run
      1. feign.hystrix.HystrixInvocationHandler$1.run(HystrixInvocationHandler.java:97)[feign-hystrix-8.16.2.jar:8.16.2]
      1 frame
    4. hystrix-core
      HystrixCommand$1.call
      1. com.netflix.hystrix.HystrixCommand$1.call(HystrixCommand.java:293)[hystrix-core-1.5.3.jar:1.5.3]
      2. com.netflix.hystrix.HystrixCommand$1.call(HystrixCommand.java:289)[hystrix-core-1.5.3.jar:1.5.3]
      2 frames
    5. rxjava
      OperatorSubscribeOn$1.call
      1. rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:46)[rxjava-1.1.5.jar:1.1.5]
      2. rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35)[rxjava-1.1.5.jar:1.1.5]
      3. rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)[rxjava-1.1.5.jar:1.1.5]
      4. rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)[rxjava-1.1.5.jar:1.1.5]
      5. rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)[rxjava-1.1.5.jar:1.1.5]
      6. rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)[rxjava-1.1.5.jar:1.1.5]
      7. rx.Observable.unsafeSubscribe(Observable.java:8460)[rxjava-1.1.5.jar:1.1.5]
      8. rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:51)[rxjava-1.1.5.jar:1.1.5]
      9. rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35)[rxjava-1.1.5.jar:1.1.5]
      10. rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)[rxjava-1.1.5.jar:1.1.5]
      11. rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)[rxjava-1.1.5.jar:1.1.5]
      12. rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)[rxjava-1.1.5.jar:1.1.5]
      13. rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)[rxjava-1.1.5.jar:1.1.5]
      14. rx.Observable.unsafeSubscribe(Observable.java:8460)[rxjava-1.1.5.jar:1.1.5]
      15. rx.internal.operators.OperatorSubscribeOn$1.call(OperatorSubscribeOn.java:94)[rxjava-1.1.5.jar:1.1.5]
      15 frames
    6. hystrix-core
      HystrixContexSchedulerAction.call
      1. com.netflix.hystrix.strategy.concurrency.HystrixContexSchedulerAction$1.call(HystrixContexSchedulerAction.java:56)[hystrix-core-1.5.3.jar:1.5.3]
      2. com.netflix.hystrix.strategy.concurrency.HystrixContexSchedulerAction$1.call(HystrixContexSchedulerAction.java:47)[hystrix-core-1.5.3.jar:1.5.3]
      3. com.netflix.hystrix.strategy.concurrency.HystrixContexSchedulerAction.call(HystrixContexSchedulerAction.java:69)[hystrix-core-1.5.3.jar:1.5.3]
      3 frames
    7. rxjava
      ScheduledAction.run
      1. rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)[rxjava-1.1.5.jar:1.1.5]
      1 frame
    8. Java RT
      Thread.run
      1. java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[na:1.8.0_72]
      2. java.util.concurrent.FutureTask.run(FutureTask.java:266)[na:1.8.0_72]
      3. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[na:1.8.0_72]
      4. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[na:1.8.0_72]
      5. java.lang.Thread.run(Thread.java:745)[na:1.8.0_72]
      5 frames