Uploaded image for project: 'Spring Data Commons'
  1. Spring Data Commons
  2. DATACMNS-972

NullPointerException in ProjectingJackson2HttpMessageConverter

    XMLWordPrintable

    Details

      Description

      Managed to get a nullpointer after switching to spring-boot 1.5.0.RC1 from 1.4.3.RELEASE

      Nullpointer happens because the "rawType" is null when the "type" is generic type(like T or D).

      Class<?> rawType = ResolvableType.forType(type).getRawClass();
      at
      spring-data-commons-1.13.0.RC1-sources.jar!/org/springframework/data/web/config/SpringDataWebConfiguration.java:121
      

      With generic type the "targetClass" is initialised here correctly using ResolvableType.forMethodParameter(parameter).resolve():

      spring-webmvc-4.3.5.RELEASE-sources.jar!/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodArgumentResolver.java:182
      

      The new "ProjectingJackson2HttpMessageConverter" converter is initialized as first converter here because spring-boot defines json-path depenency.

      spring-data-commons-1.13.0.RC1-sources.jar!/org/springframework/data/web/ProjectingJackson2HttpMessageConverter.java:127
      

      Stacktrace:

      java.lang.NullPointerException: null
      	at org.springframework.data.web.ProjectingJackson2HttpMessageConverter.canRead(ProjectingJackson2HttpMessageConverter.java:127)
      	at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:195)
      	at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.readWithMessageConverters(RequestResponseBodyMethodProcessor.java:150)
      	at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:128)
      

        Attachments

          Activity

            People

            Assignee:
            olivergierke Oliver Drotbohm
            Reporter:
            allar Allar Saarnak
            Last updater:
            Spring Issues Spring Issues
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: