java.lang.NoSuchMethodError: org.springframework.data.mongodb.core.mapping.MongoPersistentEntity.getPreferredConstructor()Lorg/springframework/data/mapping/PreferredConstructor;

Spring JIRA | Marty Pitt | 5 years ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  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.NoSuchMethodError: org.springframework.data.mongodb.core.mapping.MongoPersistentEntity.getPreferredConstructor()Lorg/springframework/data/mapping/PreferredConstructor;
  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.NoSuchMethodError: org.springframework.data.mongodb.core.mapping.MongoPersistentEntity.getPreferredConstructor()Lorg/springframework/data/mapping/PreferredConstructor;

    Root Cause Analysis

    1. 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>()
    2. Spring Data MongoDB - Core
      MappingMongoConverter.read
      1. org.springframework.data.mongodb.core.convert.MappedConstructor.<init>(MappedConstructor.java:56)
      2. org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:212)
      3. org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:200)
      4. org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:164)
      5. org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:73)
      5 frames