org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.time.OffsetDateTime to type java.util.Calendar

Spring JIRA | Petar Tahchiev | 2 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Hello, now that hibernate5 is out, I migrated all my JPA entities to use {{OffsetDateTime}} and of course the {{lastModifiedDate}} is now also {{OffsetDateTime}}. However, my tests started failing now with this exception: {code} org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.time.OffsetDateTime to type java.util.Calendar at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:313) at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:195) at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:176) at org.springframework.data.auditing.DefaultAuditableBeanWrapperFactory$DateConvertingAuditableBeanWrapper.getAsCalendar(DefaultAuditableBeanWrapperFactory.java:208) at org.springframework.data.auditing.MappingAuditableBeanWrapperFactory$MappingMetadataAuditableBeanWrapper.getLastModifiedDate(MappingAuditableBeanWrapperFactory.java:210) at org.springframework.data.rest.webmvc.AbstractRepositoryRestController.prepareHeaders(AbstractRepositoryRestController.java:180) at org.springframework.data.rest.webmvc.RepositoryEntityController.getItemResource(RepositoryEntityController.java:324) {code} And I saw that in {{AbstractRepositoryRestController:180}} there's a cast to {{java.util.Calendar}} {code} Calendar lastModifiedDate = wrapper.getLastModifiedDate(); {code} And I also noticed the class {{DateTimeConverters}} in {{spring-context}} which is missing an {{OffsetDateTimeToCalendarConverter}} - maybe one should be added?!

    Spring JIRA | 2 years ago | Petar Tahchiev
    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.time.OffsetDateTime to type java.util.Calendar
  2. 0

    Hello, now that hibernate5 is out, I migrated all my JPA entities to use {{OffsetDateTime}} and of course the {{lastModifiedDate}} is now also {{OffsetDateTime}}. However, my tests started failing now with this exception: {code} org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.time.OffsetDateTime to type java.util.Calendar at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:313) at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:195) at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:176) at org.springframework.data.auditing.DefaultAuditableBeanWrapperFactory$DateConvertingAuditableBeanWrapper.getAsCalendar(DefaultAuditableBeanWrapperFactory.java:208) at org.springframework.data.auditing.MappingAuditableBeanWrapperFactory$MappingMetadataAuditableBeanWrapper.getLastModifiedDate(MappingAuditableBeanWrapperFactory.java:210) at org.springframework.data.rest.webmvc.AbstractRepositoryRestController.prepareHeaders(AbstractRepositoryRestController.java:180) at org.springframework.data.rest.webmvc.RepositoryEntityController.getItemResource(RepositoryEntityController.java:324) {code} And I saw that in {{AbstractRepositoryRestController:180}} there's a cast to {{java.util.Calendar}} {code} Calendar lastModifiedDate = wrapper.getLastModifiedDate(); {code} And I also noticed the class {{DateTimeConverters}} in {{spring-context}} which is missing an {{OffsetDateTimeToCalendarConverter}} - maybe one should be added?!

    Spring JIRA | 2 years ago | Petar Tahchiev
    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.time.OffsetDateTime to type java.util.Calendar

    Root Cause Analysis

    1. org.springframework.web.util.NestedServletException

      Request processing failed; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.time.OffsetDateTime to type java.util.Calendar

      at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound()
    2. Spring Core
      GenericConversionService.convert
      1. org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:313)
      2. org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:195)
      3. org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:176)
      3 frames
    3. Spring Data Core
      MappingAuditableBeanWrapperFactory$MappingMetadataAuditableBeanWrapper.getLastModifiedDate
      1. org.springframework.data.auditing.DefaultAuditableBeanWrapperFactory$DateConvertingAuditableBeanWrapper.getAsCalendar(DefaultAuditableBeanWrapperFactory.java:208)
      2. org.springframework.data.auditing.MappingAuditableBeanWrapperFactory$MappingMetadataAuditableBeanWrapper.getLastModifiedDate(MappingAuditableBeanWrapperFactory.java:210)
      2 frames
    4. Spring Data REST - WebMVC
      RepositoryEntityController.getItemResource
      1. org.springframework.data.rest.webmvc.AbstractRepositoryRestController.prepareHeaders(AbstractRepositoryRestController.java:180)
      2. org.springframework.data.rest.webmvc.RepositoryEntityController.getItemResource(RepositoryEntityController.java:324)
      2 frames