org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.lang.String to type @org.springframework.data.repository.query.Param com.nemesis.platform.core.definition.catalog.CatalogVersionModelDefinition

Spring JIRA | Petar Tahchiev | 2 years ago
  1. 0

    Hello, I have my repositories to work with interfaces, instead of entity classes, like this: {code} @Repository(value = ProductRepository.NAME) @RepositoryRestResource(itemResourceRel = ProductModelDefinition.NAME, path = ProductModelDefinition.NAME, collectionResourceRel = ProductModelDefinition.NAME) public interface ProductRepository extends BaseCatalogableEntityRepository<ProductModelDefinition, Long> { @RestResource(exported = false) Page<ProductModelDefinition> findAllByCatalogVersionAndVariantTypeIsNotNull(@Param("catalogVersion") final CatalogVersionModelDefinition catalogVersion, final Pageable pageable); } {code} and it all works fine until I try to call the method {{findAllByCatalogVersionAndVariantTypeIsNotNull}} over rest. Then I get this exception: {code} 2015-02-02 18:53:09,958 org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/storefront].[restDispatcherServlet] [http-nio-8112-exec-7] ERROR: Servlet.service() for servlet [restDispatcherServlet] in context with path [/storefront] threw exception [Request processing failed; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.lang.String to type @org.springframework.data.repository.query.Param com.nemesis.platform.core.definition.catalog.CatalogVersionModelDefinition] with root cause org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.lang.String to type @org.springframework.data.repository.query.Param com.nemesis.platform.core.definition.catalog.CatalogVersionModelDefinition at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:311) at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:192) at org.springframework.data.repository.support.ReflectionRepositoryInvoker.prepareParameters(ReflectionRepositoryInvoker.java:214) at org.springframework.data.repository.support.ReflectionRepositoryInvoker.invokeQueryMethod(ReflectionRepositoryInvoker.java:179) at org.springframework.data.rest.webmvc.RepositorySearchController.executeQueryMethod(RepositorySearchController.java:278) at org.springframework.data.rest.webmvc.RepositorySearchController.executeSearch(RepositorySearchController.java:168) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) {code} I tried to register a custom converter (from {{String}} to {{CatalogVersionModelDefinition}}), but I only have access to the string parameter and this means I have to register converters for all the entities. If I map the converter to the base interface ({{CatalogVersionModelDefinition}} extends another interface) it doesn't get invoked. Maybe the best solution would be to call the registered {{RepositoryMetadata::findDomainClass()}} method before searching in the conversion service.

    Spring JIRA | 2 years ago | Petar Tahchiev
    org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.lang.String to type @org.springframework.data.repository.query.Param com.nemesis.platform.core.definition.catalog.CatalogVersionModelDefinition
  2. 0

    Hello, I have my repositories to work with interfaces, instead of entity classes, like this: {code} @Repository(value = ProductRepository.NAME) @RepositoryRestResource(itemResourceRel = ProductModelDefinition.NAME, path = ProductModelDefinition.NAME, collectionResourceRel = ProductModelDefinition.NAME) public interface ProductRepository extends BaseCatalogableEntityRepository<ProductModelDefinition, Long> { @RestResource(exported = false) Page<ProductModelDefinition> findAllByCatalogVersionAndVariantTypeIsNotNull(@Param("catalogVersion") final CatalogVersionModelDefinition catalogVersion, final Pageable pageable); } {code} and it all works fine until I try to call the method {{findAllByCatalogVersionAndVariantTypeIsNotNull}} over rest. Then I get this exception: {code} 2015-02-02 18:53:09,958 org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/storefront].[restDispatcherServlet] [http-nio-8112-exec-7] ERROR: Servlet.service() for servlet [restDispatcherServlet] in context with path [/storefront] threw exception [Request processing failed; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.lang.String to type @org.springframework.data.repository.query.Param com.nemesis.platform.core.definition.catalog.CatalogVersionModelDefinition] with root cause org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.lang.String to type @org.springframework.data.repository.query.Param com.nemesis.platform.core.definition.catalog.CatalogVersionModelDefinition at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:311) at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:192) at org.springframework.data.repository.support.ReflectionRepositoryInvoker.prepareParameters(ReflectionRepositoryInvoker.java:214) at org.springframework.data.repository.support.ReflectionRepositoryInvoker.invokeQueryMethod(ReflectionRepositoryInvoker.java:179) at org.springframework.data.rest.webmvc.RepositorySearchController.executeQueryMethod(RepositorySearchController.java:278) at org.springframework.data.rest.webmvc.RepositorySearchController.executeSearch(RepositorySearchController.java:168) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) {code} I tried to register a custom converter (from {{String}} to {{CatalogVersionModelDefinition}}), but I only have access to the string parameter and this means I have to register converters for all the entities. If I map the converter to the base interface ({{CatalogVersionModelDefinition}} extends another interface) it doesn't get invoked. Maybe the best solution would be to call the registered {{RepositoryMetadata::findDomainClass()}} method before searching in the conversion service.

    Spring JIRA | 2 years ago | Petar Tahchiev
    org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.lang.String to type @org.springframework.data.repository.query.Param com.nemesis.platform.core.definition.catalog.CatalogVersionModelDefinition
  3. 0

    Entity report does not work

    GitHub | 2 years ago | Mark-de-Haan
    org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.util.HashMap<?, ?> to type java.lang.String
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Configurar Grails con MySql | groovy | Iteramos.com

    iteramos.com | 1 year ago
    org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.lang.Class<?> to type java.lang.String

  1. shiva768 1 times, last 12 months ago
9 unregistered visitors
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.ConverterNotFoundException

    No converter found capable of converting from type java.lang.String to type @org.springframework.data.repository.query.Param com.nemesis.platform.core.definition.catalog.CatalogVersionModelDefinition

    at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound()
  2. Spring Core
    GenericConversionService.convert
    1. org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:311)
    2. org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:192)
    2 frames
  3. Spring Data Core
    ReflectionRepositoryInvoker.invokeQueryMethod
    1. org.springframework.data.repository.support.ReflectionRepositoryInvoker.prepareParameters(ReflectionRepositoryInvoker.java:214)
    2. org.springframework.data.repository.support.ReflectionRepositoryInvoker.invokeQueryMethod(ReflectionRepositoryInvoker.java:179)
    2 frames
  4. Spring Data REST - WebMVC
    RepositorySearchController.executeSearch
    1. org.springframework.data.rest.webmvc.RepositorySearchController.executeQueryMethod(RepositorySearchController.java:278)
    2. org.springframework.data.rest.webmvc.RepositorySearchController.executeSearch(RepositorySearchController.java:168)
    2 frames
  5. Java RT
    NativeMethodAccessorImpl.invoke0
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    1 frame