java.lang.NullPointerException

Spring JIRA | Marty Pitt | 5 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

    I have a project that combines both MongoDB and JPA persistence strategies, so uses both of the associated projects. After upgrading versions, I've found series of exceptions thrown. Initially I was using: {code:xml} <properties> <spring.data.jpa.version> 1.1.0.BUILD-SNAPSHOT</spring.data.jpa.version> <spring.data.mongo.version>1.0.0.RC1</spring.data.mongo.version> <query.dsl.version>2.3.0</query.dsl.version> </properties> {code} However, I'm assuming the snapshot has changed, because this is now throwing an excepition: {noformat} java.lang.NoClassDefFoundError: org/springframework/data/mapping/model/SpELAwareParameterValueProvider {noformat} I then upgraded to the following: {code:xml} <properties> <spring.data.jpa.version>1.1.0.RC1</spring.data.jpa.version> <spring.data.mongo.version>1.0.1.RELEASE</spring.data.mongo.version> <query.dsl.version>2.3.0</query.dsl.version> </properties> {code} Which rendered the following exception: {noformat} java.lang.NoSuchMethodError: org.springframework.data.mongodb.core.mapping.MongoPersistentEntity.getPreferredConstructor()Lorg/springframework/data/mapping/PreferredConstructor; at org.springframework.data.mongodb.core.convert.MappedConstructor.<init>(MappedConstructor.java:56) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:212) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:200) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:164) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:73) … {noformat} After further investigation, it appears the conflict is in the dependency versions of spring-data-commons-core * spring-data-jpa:1.1.0.RC1 -> spring-data-commons-core:1.3.0.BUILD-SNAPSHOT * spring-data-mongodb:1.0.1.RELEASE -> spring-data-commons-core:1.2.1.RELEASE I then tried the following: {code:xml} <properties> <spring.data.jpa.version>1.1.0.RC1</spring.data.jpa.version> <spring.data.mongo.version>1.1.0.BUILD-SNAPSHOT</spring.data.mongo.version> <query.dsl.version>2.3.0</query.dsl.version> </properties> {code} Which resulted in a {{NullPointerException}}, as follows: {noformat} java.lang.NullPointerException at org.springframework.data.mongodb.core.convert.MappingMongoConverter$MongoDbPropertyValueProvider.getPropertyValue(MappingMongoConverter.java:899) at org.springframework.data.mongodb.core.convert.MappingMongoConverter$MongoDbPropertyValueProvider.getPropertyValue(MappingMongoConverter.java:874) at org.springframework.data.mapping.model.PersistentEntityParameterValueProvider.getParameterValue(PersistentEntityParameterValueProvider.java:77) at org.springframework.data.convert.ReflectionEntityInstantiator.createInstance(ReflectionEntityInstantiator.java:70) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:226) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:206) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:170) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:73) at org.springframework.data.mongodb.core.MongoTemplate$ReadDbObjectCallback.doWith(MongoTemplate.java:1686) at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1437) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1252) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1241) at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:467) at org.springframework.data.mongodb.repository.support.SimpleMongoRepository.findAll(SimpleMongoRepository.java:220) at org.springframework.data.mongodb.repository.support.SimpleMongoRepository.findAll(SimpleMongoRepository.java:176) at org.springframework.data.mongodb.repository.support.SimpleMongoRepository.findAll(SimpleMongoRepository.java:45) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:323) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:308) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) … {noformat} As it stands, there doesn't appear to be a working combination of JPA/MongoDB/Core that is usable.

    Spring JIRA | 5 years ago | Marty Pitt
    java.lang.NullPointerException
  2. 0

    I have a project that combines both MongoDB and JPA persistence strategies, so uses both of the associated projects. After upgrading versions, I've found series of exceptions thrown. Initially I was using: {code:xml} <properties> <spring.data.jpa.version> 1.1.0.BUILD-SNAPSHOT</spring.data.jpa.version> <spring.data.mongo.version>1.0.0.RC1</spring.data.mongo.version> <query.dsl.version>2.3.0</query.dsl.version> </properties> {code} However, I'm assuming the snapshot has changed, because this is now throwing an excepition: {noformat} java.lang.NoClassDefFoundError: org/springframework/data/mapping/model/SpELAwareParameterValueProvider {noformat} I then upgraded to the following: {code:xml} <properties> <spring.data.jpa.version>1.1.0.RC1</spring.data.jpa.version> <spring.data.mongo.version>1.0.1.RELEASE</spring.data.mongo.version> <query.dsl.version>2.3.0</query.dsl.version> </properties> {code} Which rendered the following exception: {noformat} java.lang.NoSuchMethodError: org.springframework.data.mongodb.core.mapping.MongoPersistentEntity.getPreferredConstructor()Lorg/springframework/data/mapping/PreferredConstructor; at org.springframework.data.mongodb.core.convert.MappedConstructor.<init>(MappedConstructor.java:56) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:212) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:200) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:164) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:73) … {noformat} After further investigation, it appears the conflict is in the dependency versions of spring-data-commons-core * spring-data-jpa:1.1.0.RC1 -> spring-data-commons-core:1.3.0.BUILD-SNAPSHOT * spring-data-mongodb:1.0.1.RELEASE -> spring-data-commons-core:1.2.1.RELEASE I then tried the following: {code:xml} <properties> <spring.data.jpa.version>1.1.0.RC1</spring.data.jpa.version> <spring.data.mongo.version>1.1.0.BUILD-SNAPSHOT</spring.data.mongo.version> <query.dsl.version>2.3.0</query.dsl.version> </properties> {code} Which resulted in a {{NullPointerException}}, as follows: {noformat} java.lang.NullPointerException at org.springframework.data.mongodb.core.convert.MappingMongoConverter$MongoDbPropertyValueProvider.getPropertyValue(MappingMongoConverter.java:899) at org.springframework.data.mongodb.core.convert.MappingMongoConverter$MongoDbPropertyValueProvider.getPropertyValue(MappingMongoConverter.java:874) at org.springframework.data.mapping.model.PersistentEntityParameterValueProvider.getParameterValue(PersistentEntityParameterValueProvider.java:77) at org.springframework.data.convert.ReflectionEntityInstantiator.createInstance(ReflectionEntityInstantiator.java:70) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:226) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:206) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:170) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:73) at org.springframework.data.mongodb.core.MongoTemplate$ReadDbObjectCallback.doWith(MongoTemplate.java:1686) at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1437) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1252) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1241) at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:467) at org.springframework.data.mongodb.repository.support.SimpleMongoRepository.findAll(SimpleMongoRepository.java:220) at org.springframework.data.mongodb.repository.support.SimpleMongoRepository.findAll(SimpleMongoRepository.java:176) at org.springframework.data.mongodb.repository.support.SimpleMongoRepository.findAll(SimpleMongoRepository.java:45) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:323) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:308) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) … {noformat} As it stands, there doesn't appear to be a working combination of JPA/MongoDB/Core that is usable.

    Spring JIRA | 5 years ago | Marty Pitt
    java.lang.NullPointerException
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at org.springframework.data.mongodb.core.convert.MappingMongoConverter$MongoDbPropertyValueProvider.getPropertyValue()
    2. Spring Data MongoDB - Core
      MappingMongoConverter$MongoDbPropertyValueProvider.getPropertyValue
      1. org.springframework.data.mongodb.core.convert.MappingMongoConverter$MongoDbPropertyValueProvider.getPropertyValue(MappingMongoConverter.java:899)
      2. org.springframework.data.mongodb.core.convert.MappingMongoConverter$MongoDbPropertyValueProvider.getPropertyValue(MappingMongoConverter.java:874)
      2 frames
    3. Spring Data Core
      ReflectionEntityInstantiator.createInstance
      1. org.springframework.data.mapping.model.PersistentEntityParameterValueProvider.getParameterValue(PersistentEntityParameterValueProvider.java:77)
      2. org.springframework.data.convert.ReflectionEntityInstantiator.createInstance(ReflectionEntityInstantiator.java:70)
      2 frames
    4. Spring Data MongoDB - Core
      SimpleMongoRepository.findAll
      1. org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:226)
      2. org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:206)
      3. org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:170)
      4. org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:73)
      5. org.springframework.data.mongodb.core.MongoTemplate$ReadDbObjectCallback.doWith(MongoTemplate.java:1686)
      6. org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1437)
      7. org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1252)
      8. org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1241)
      9. org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:467)
      10. org.springframework.data.mongodb.repository.support.SimpleMongoRepository.findAll(SimpleMongoRepository.java:220)
      11. org.springframework.data.mongodb.repository.support.SimpleMongoRepository.findAll(SimpleMongoRepository.java:176)
      12. org.springframework.data.mongodb.repository.support.SimpleMongoRepository.findAll(SimpleMongoRepository.java:45)
      12 frames
    5. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:597)
      4 frames
    6. Spring Data Core
      RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke
      1. org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:323)
      2. org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:308)
      2 frames
    7. Spring AOP
      JdkDynamicAopProxy.invoke
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      2. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      2 frames