Skip to content

[3.2.1] Indexing Class with Custom Converter -> Couldn't find PersistentEntity for property private [...] #3659

Closed

Description

@IsNull

We updated from spring boot 2.4.2 to 2.5.0, and now Index creation is broken. This means the same code that worked before wont under 2.5.0. (spring-data-mongodb 3.1.3 to 3.2.1 )


I have created a sample Project which shows the problem: https://gitlab.com/elderbyte/public/examples/spring-mongo-index-issue


Creating an mongo index fails, when the dot path notation is used and the referenced class is in a separate library has a custom mongo converter:

@Configuration
@EnableMongoRepositories()
public class DefaultMongoConfiguration {


    @Bean
    public MongoCustomConversions customConversions(){
        var converters = new ArrayList<Converter<?,?>>();
        converters.add(new MyAddressToDocumentConverter()); // Comment this out, and it works
        return new MongoCustomConversions(converters);
    }

    @WritingConverter
    public static class MyAddressToDocumentConverter implements Converter<MyAddress, Document> {
        @Override
        public Document convert(MyAddress address) {
            var doc = new Document();
            doc.put("street", address.getStreet());
            return doc;
        }
    }
}

The entity for which this index is being defined looks like this (simplified):

@Document
public class Customer {

    @Id
    private ObjectId id;

    private String name;

    private MyAddress address;

}
public class MyAddress {

    private String street;

    public String getStreet() {
        return street;
    }

    public void setStreet(String street) {
        this.street = street;
    }
}

Creating an Index via ensure index yields an unexpected exception:

        indexOps.ensureIndex(
                TextIndexDefinition
                        .builder()
                        .named("TextIndex")
                        .onField("name")
                        .onField("address.street")
                        .build()
        );

Stacktrace

org.springframework.data.mapping.MappingException: Couldn't find PersistentEntity for property private com.elderbyte.starter.demo.domain.customers.MyAddress com.elderbyte.starter.demo.domain.customers.Customer.address!
	at org.springframework.data.mapping.context.MappingContext.getRequiredPersistentEntity(MappingContext.java:152) ~[spring-data-commons-2.5.1.jar:2.5.1]
	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.getPair(PersistentPropertyPathFactory.java:225) ~[spring-data-commons-2.5.1.jar:2.5.1]
	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.createPersistentPropertyPath(PersistentPropertyPathFactory.java:199) ~[spring-data-commons-2.5.1.jar:2.5.1]
	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.lambda$getPersistentPropertyPath$1(PersistentPropertyPathFactory.java:172) ~[spring-data-commons-2.5.1.jar:2.5.1]
	at java.base/java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:330) ~[na:na]
	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.getPersistentPropertyPath(PersistentPropertyPathFactory.java:171) ~[spring-data-commons-2.5.1.jar:2.5.1]
	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.from(PersistentPropertyPathFactory.java:86) ~[spring-data-commons-2.5.1.jar:2.5.1]
	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.from(PersistentPropertyPathFactory.java:99) ~[spring-data-commons-2.5.1.jar:2.5.1]
	at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentPropertyPath(AbstractMappingContext.java:285) ~[spring-data-commons-2.5.1.jar:2.5.1]
	at org.springframework.data.mongodb.core.convert.QueryMapper$MetadataBackedField.getPath(QueryMapper.java:1183) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
	at org.springframework.data.mongodb.core.convert.QueryMapper$MetadataBackedField.<init>(QueryMapper.java:1045) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
	at org.springframework.data.mongodb.core.convert.QueryMapper$MetadataBackedField.<init>(QueryMapper.java:1022) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
	at org.springframework.data.mongodb.core.convert.QueryMapper.createPropertyField(QueryMapper.java:329) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
	at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedSort(QueryMapper.java:197) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
	at org.springframework.data.mongodb.core.DefaultIndexOperations.lambda$ensureIndex$0(DefaultIndexOperations.java:130) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
	at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:553) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
	at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:539) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
	at org.springframework.data.mongodb.core.DefaultIndexOperations.execute(DefaultIndexOperations.java:211) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
	at org.springframework.data.mongodb.core.DefaultIndexOperations.ensureIndex(DefaultIndexOperations.java:121) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
	at com.elderbyte.starter.demo.domain.customers.CustomerIndexConfiguration.initIndicesAfterStartup(CustomerIndexConfiguration.java:54) ~[main/:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
	at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:344) ~[spring-context-5.3.7.jar:5.3.7]
	at org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent(ApplicationListenerMethodAdapter.java:229) ~[spring-context-5.3.7.jar:5.3.7]
	at org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent(ApplicationListenerMethodAdapter.java:166) ~[spring-context-5.3.7.jar:5.3.7]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[spring-context-5.3.7.jar:5.3.7]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[spring-context-5.3.7.jar:5.3.7]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[spring-context-5.3.7.jar:5.3.7]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421) ~[spring-context-5.3.7.jar:5.3.7]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378) ~[spring-context-5.3.7.jar:5.3.7]
	at org.springframework.boot.context.event.EventPublishingRunListener.running(EventPublishingRunListener.java:111) ~[spring-boot-2.5.0.jar:2.5.0]
	at org.springframework.boot.SpringApplicationRunListeners.lambda$running$6(SpringApplicationRunListeners.java:79) ~[spring-boot-2.5.0.jar:2.5.0]
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) ~[na:na]
	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117) ~[spring-boot-2.5.0.jar:2.5.0]
	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111) ~[spring-boot-2.5.0.jar:2.5.0]
	at org.springframework.boot.SpringApplicationRunListeners.running(SpringApplicationRunListeners.java:79) ~[spring-boot-2.5.0.jar:2.5.0]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:352) ~[spring-boot-2.5.0.jar:2.5.0]
	at com.elderbyte.starter.demo.MongodbDemoServer.main(MongodbDemoServer.java:21) ~[main/:na]

2021-05-27 10:59:59.330  INFO 9895 --- [           main] o.s.b.a.ApplicationAvailabilityBean      : Application availability state ReadinessState changed to REFUSING_TRAFFIC
2021-05-27 10:59:59.358  INFO 9895 --- [           main] org.mongodb.driver.connection            : Closed connection [connectionId{localValue:3, serverValue:840}] to localhost:27017 because the pool has been closed.

Process finished with exit code 1

Conclusions:

  • We observed the problem first with Spring Boot 2.5.0 which uses the version 3.2.1 of spring-data-mongodb
    • Therefore it looks like a regression from Spring Boot 2.4.2 where the same code works (3.1.3 of spring-data-mongodb)
    • Edit: Spring Boot 2.4.6 also works (3.1.9 spring-data-mongodb)
  • The class com.elderbyte.commons.i18n.I18nText is in another library which is a gradle (maven) dependency.
  • Repository Base package has been set to com.elderbyte so it should include both classes
  • If I copy the class from that library into the local project, it works.
  • It seems to be caused by the custom converter.
  • If the custom converter is not registered, it works.

Any idea what could have caused this and how to fix it?

Activity

  1. christophstrobl commented on May 26, 2021

    @christophstrobl
    Member

    Can you please add the structure of all involved classes (I18nText, MaterialPackaging) and the actual call to index ops.
    A Minimal, Reproducible Example would help us triage the issue.

  2. added
    status: waiting-for-feedback
    and removed
    status: waiting-for-triage
    on May 26, 2021
  3. IsNull commented on May 26, 2021

    @IsNull
    Author

    @christophstrobl Thanks for your feedback. While trying to distill a minimal example, I figured out that the issue arises when the following mongo converter is enabled:

        @WritingConverter
        public static class IntervalToDocumentConverter implements Converter<Interval, Document> {
            @Override
            public Document convert(Interval interval) {
                var doc = new Document();
                doc.put("start", Date.from(interval.getStart()));
                doc.put("end", Date.from(interval.getEnd()));
                return doc;
            }
        }

    The converter gets registered via MongoCustomConversions.

    The Entity:

    @Document
    public class Customer {
        @Id
        private ObjectId id;
    
        private String name;
        
        private Interval validInterval;
    }

    Index creation

    public void initIndicesAfterStartup() {
    
            var indexOps = mongoOperations.indexOps(Customer.class);
    
            try {
                indexOps.dropIndex("TextIndex");
            }catch (Exception e){}
    
            indexOps.ensureIndex(
                    TextIndexDefinition
                            .builder()
                            .named("TextIndex")
                            .onField("name")
                            .onField("validInterval.start")
                            .build()
            );
        }

    With the converter registered, it leads to the following error:

    
    org.springframework.data.mapping.MappingException: Couldn't find PersistentEntity for property private com.elderbyte.commons.time.Interval com.elderbyte.starter.demo.domain.customers.Customer.validInterval!
    	at org.springframework.data.mapping.context.MappingContext.getRequiredPersistentEntity(MappingContext.java:152) ~[spring-data-commons-2.5.1.jar:2.5.1]
    	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.getPair(PersistentPropertyPathFactory.java:225) ~[spring-data-commons-2.5.1.jar:2.5.1]
    	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.createPersistentPropertyPath(PersistentPropertyPathFactory.java:199) ~[spring-data-commons-2.5.1.jar:2.5.1]
    	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.lambda$getPersistentPropertyPath$1(PersistentPropertyPathFactory.java:172) ~[spring-data-commons-2.5.1.jar:2.5.1]
    	at org.springframework.data.mapping.context.PersistentPropertyPathFactory$$Lambda$1085/0x000000002043ef70.apply(Unknown Source) ~[na:na]
    	at java.base/java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:330) ~[na:na]
    	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.getPersistentPropertyPath(PersistentPropertyPathFactory.java:171) ~[spring-data-commons-2.5.1.jar:2.5.1]
    	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.from(PersistentPropertyPathFactory.java:86) ~[spring-data-commons-2.5.1.jar:2.5.1]
    	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.from(PersistentPropertyPathFactory.java:99) ~[spring-data-commons-2.5.1.jar:2.5.1]
    	at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentPropertyPath(AbstractMappingContext.java:285) ~[spring-data-commons-2.5.1.jar:2.5.1]
    	at org.springframework.data.mongodb.core.convert.QueryMapper$MetadataBackedField.getPath(QueryMapper.java:1183) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
    	at org.springframework.data.mongodb.core.convert.QueryMapper$MetadataBackedField.<init>(QueryMapper.java:1045) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
    	at org.springframework.data.mongodb.core.convert.QueryMapper$MetadataBackedField.<init>(QueryMapper.java:1022) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
    	at org.springframework.data.mongodb.core.convert.QueryMapper.createPropertyField(QueryMapper.java:329) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
    	at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedSort(QueryMapper.java:197) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
    	at org.springframework.data.mongodb.core.DefaultIndexOperations.lambda$ensureIndex$0(DefaultIndexOperations.java:130) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
    	at org.springframework.data.mongodb.core.DefaultIndexOperations$$Lambda$1081/0x00000000204395d8.doInCollection(Unknown Source) ~[na:na]
    	at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:553) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
    	at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:539) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
    	at org.springframework.data.mongodb.core.DefaultIndexOperations.execute(DefaultIndexOperations.java:211) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
    	at org.springframework.data.mongodb.core.DefaultIndexOperations.ensureIndex(DefaultIndexOperations.java:121) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
    	at com.elderbyte.starter.demo.domain.customers.CustomerIndexConfiguration.initIndicesAfterStartup(CustomerIndexConfiguration.java:54) ~[main/:na]
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[na:na]
    	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    	at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
    	at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:344) ~[spring-context-5.3.7.jar:5.3.7]
    	at org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent(ApplicationListenerMethodAdapter.java:229) ~[spring-context-5.3.7.jar:5.3.7]
    	at org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent(ApplicationListenerMethodAdapter.java:166) ~[spring-context-5.3.7.jar:5.3.7]
    	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[spring-context-5.3.7.jar:5.3.7]
    	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[spring-context-5.3.7.jar:5.3.7]
    	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[spring-context-5.3.7.jar:5.3.7]
    	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421) ~[spring-context-5.3.7.jar:5.3.7]
    	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378) ~[spring-context-5.3.7.jar:5.3.7]
    	at org.springframework.boot.context.event.EventPublishingRunListener.running(EventPublishingRunListener.java:111) ~[spring-boot-2.5.0.jar:2.5.0]
    	at org.springframework.boot.SpringApplicationRunListeners.lambda$running$6(SpringApplicationRunListeners.java:79) ~[spring-boot-2.5.0.jar:2.5.0]
    	at org.springframework.boot.SpringApplicationRunListeners$$Lambda$1071/0x0000000020016978.accept(Unknown Source) ~[na:na]
    	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) ~[na:na]
    	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117) ~[spring-boot-2.5.0.jar:2.5.0]
    	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111) ~[spring-boot-2.5.0.jar:2.5.0]
    	at org.springframework.boot.SpringApplicationRunListeners.running(SpringApplicationRunListeners.java:79) ~[spring-boot-2.5.0.jar:2.5.0]
    	at org.springframework.boot.SpringApplication.run(SpringApplication.java:352) ~[spring-boot-2.5.0.jar:2.5.0]
    	at com.elderbyte.starter.demo.MongodbDemoServer.main(MongodbDemoServer.java:21) ~[main/:na]
    

    If I disable the converter it works.
    It affects all classes I've tested which have a custom converter registered.

  4. added
    status: feedback-provided
    and removed
    status: waiting-for-feedback
    on May 26, 2021
  5. IsNull commented on May 26, 2021

    @IsNull
    Author

    Here is an minimal example project. Simply start the App Server and you will see the exception.

    https://gitlab.com/elderbyte/public/examples/spring-mongo-index-issue

  6. changed the title [-][3.2.1] Indexing Class from library -> Couldn't find PersistentEntity for property private [...][/-] [+][3.2.1] Indexing Class with Custom Converter -> Couldn't find PersistentEntity for property private [...][/+] on May 27, 2021
  7. IsNull commented on May 27, 2021

    @IsNull
    Author

    @christophstrobl I have now created an reproducible example project & also updated the issue description to reflect the latest discoveries.

  8. christophstrobl commented on May 27, 2021

    @christophstrobl
    Member

    thanks @IsNull - we'll have a look. Might take some time though.

  9. IsNull commented on May 28, 2021

    @IsNull
    Author

    @christophstrobl Further investigation shows that the problem is not only with custom converters defined by users, but even with standard converters provided by spring.

    For example, indexing the spring org.springframework.data.geo.Box which happens to define a MongoConverter in org.springframework.data.mongodb.core.convert.GeoConverters

    @Document
    public class Customer {
    
        @Id
        private ObjectId id;
    
        private String name;
        
        private org.springframework.data.geo.Box box;
    
    }
            indexOps.ensureIndex(
                    TextIndexDefinition
                            .builder()
                            .named("TextIndex")
                            .onField("name")
                            .onField("box.first.x")
                            .build()
            );
    

    I consider this a major bug / regression which should be fixed with high priority.

    Same Stacktrace:

    org.springframework.data.mapping.MappingException: Couldn't find PersistentEntity for property private org.springframework.data.geo.Box com.elderbyte.starter.demo.domain.customers.Customer.box!
    	at org.springframework.data.mapping.context.MappingContext.getRequiredPersistentEntity(MappingContext.java:152) ~[spring-data-commons-2.5.1.jar:2.5.1]
    	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.getPair(PersistentPropertyPathFactory.java:225) ~[spring-data-commons-2.5.1.jar:2.5.1]
    	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.createPersistentPropertyPath(PersistentPropertyPathFactory.java:199) ~[spring-data-commons-2.5.1.jar:2.5.1]
    	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.lambda$getPersistentPropertyPath$1(PersistentPropertyPathFactory.java:172) ~[spring-data-commons-2.5.1.jar:2.5.1]
    	at java.base/java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:330) ~[na:na]
    	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.getPersistentPropertyPath(PersistentPropertyPathFactory.java:171) ~[spring-data-commons-2.5.1.jar:2.5.1]
    	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.from(PersistentPropertyPathFactory.java:86) ~[spring-data-commons-2.5.1.jar:2.5.1]
    	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.from(PersistentPropertyPathFactory.java:99) ~[spring-data-commons-2.5.1.jar:2.5.1]
    	at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentPropertyPath(AbstractMappingContext.java:285) ~[spring-data-commons-2.5.1.jar:2.5.1]
    	at org.springframework.data.mongodb.core.convert.QueryMapper$MetadataBackedField.getPath(QueryMapper.java:1183) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
    	at org.springframework.data.mongodb.core.convert.QueryMapper$MetadataBackedField.<init>(QueryMapper.java:1045) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
    	at org.springframework.data.mongodb.core.convert.QueryMapper$MetadataBackedField.<init>(QueryMapper.java:1022) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
    	at org.springframework.data.mongodb.core.convert.QueryMapper.createPropertyField(QueryMapper.java:329) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
    	at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedSort(QueryMapper.java:197) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
    	at org.springframework.data.mongodb.core.DefaultIndexOperations.lambda$ensureIndex$0(DefaultIndexOperations.java:130) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
    	at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:553) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
    	at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:539) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
    	at org.springframework.data.mongodb.core.DefaultIndexOperations.execute(DefaultIndexOperations.java:211) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
    	at org.springframework.data.mongodb.core.DefaultIndexOperations.ensureIndex(DefaultIndexOperations.java:121) ~[spring-data-mongodb-3.2.1.jar:3.2.1]
    	at com.elderbyte.starter.demo.domain.customers.CustomerIndexConfiguration.initIndicesAfterStartup(CustomerIndexConfiguration.java:54) ~[main/:na]
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
    	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    	at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
    	at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:344) ~[spring-context-5.3.7.jar:5.3.7]
    	at org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent(ApplicationListenerMethodAdapter.java:229) ~[spring-context-5.3.7.jar:5.3.7]
    	at org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent(ApplicationListenerMethodAdapter.java:166) ~[spring-context-5.3.7.jar:5.3.7]
    	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[spring-context-5.3.7.jar:5.3.7]
    	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[spring-context-5.3.7.jar:5.3.7]
    	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[spring-context-5.3.7.jar:5.3.7]
    	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421) ~[spring-context-5.3.7.jar:5.3.7]
    	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378) ~[spring-context-5.3.7.jar:5.3.7]
    	at org.springframework.boot.context.event.EventPublishingRunListener.running(EventPublishingRunListener.java:111) ~[spring-boot-2.5.0.jar:2.5.0]
    	at org.springframework.boot.SpringApplicationRunListeners.lambda$running$6(SpringApplicationRunListeners.java:79) ~[spring-boot-2.5.0.jar:2.5.0]
    	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) ~[na:na]
    	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117) ~[spring-boot-2.5.0.jar:2.5.0]
    	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111) ~[spring-boot-2.5.0.jar:2.5.0]
    	at org.springframework.boot.SpringApplicationRunListeners.running(SpringApplicationRunListeners.java:79) ~[spring-boot-2.5.0.jar:2.5.0]
    	at org.springframework.boot.SpringApplication.run(SpringApplication.java:352) ~[spring-boot-2.5.0.jar:2.5.0]
    	at com.elderbyte.starter.demo.MongodbDemoServer.main(MongodbDemoServer.java:21) ~[main/:na]
    
  10. added
    type: regression
    on May 31, 2021
  11. christophstrobl commented on May 31, 2021

    @christophstrobl
    Member

    Types having a write Converter are considered custom simple types. The change introduced via spring-projects/spring-data-commons#2293 takes this into account when evaluating the property path.
    I need to take this to the team to see if we fix this in the MongoDB module only or if it requires a broader solution for all modules.

  12. added a commit that references this issue on Jun 1, 2021
    cf3e850
  13. jnaalisv commented on Jun 13, 2021

    @jnaalisv

    We are also hitting this when trying to execute MongoTemplate.updateMulti:

    org.springframework.data.mapping.MappingException: Couldn't find PersistentEntity for property private [redacted]
    
        	at org.springframework.data.mapping.context.MappingContext.getRequiredPersistentEntity(MappingContext.java:152)
        	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.getPair(PersistentPropertyPathFactory.java:225)
        	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.createPersistentPropertyPath(PersistentPropertyPathFactory.java:199)
        	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.lambda$getPersistentPropertyPath$1(PersistentPropertyPathFactory.java:172)
        	at java.base/java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:330)
        	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.getPersistentPropertyPath(PersistentPropertyPathFactory.java:171)
        	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.from(PersistentPropertyPathFactory.java:86)
        	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.from(PersistentPropertyPathFactory.java:99)
        	at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentPropertyPath(AbstractMappingContext.java:285)
        	at org.springframework.data.mongodb.core.convert.QueryMapper$MetadataBackedField.getPath(QueryMapper.java:1183)
        	at org.springframework.data.mongodb.core.convert.QueryMapper$MetadataBackedField.<init>(QueryMapper.java:1045)
        	at org.springframework.data.mongodb.core.convert.QueryMapper$MetadataBackedField.<init>(QueryMapper.java:1022)
        	at org.springframework.data.mongodb.core.convert.UpdateMapper$MetadataBackedUpdateField.<init>(UpdateMapper.java:298)
        	at org.springframework.data.mongodb.core.convert.UpdateMapper.createPropertyField(UpdateMapper.java:257)
        	at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:144)
        	at org.springframework.data.mongodb.core.convert.UpdateMapper.getMappedObject(UpdateMapper.java:68)
        	at org.springframework.data.mongodb.core.convert.QueryMapper.convertSimpleOrDocument(QueryMapper.java:520)
        	at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedKeyword(QueryMapper.java:364)
        	at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:138)
        	at org.springframework.data.mongodb.core.convert.UpdateMapper.getMappedObject(UpdateMapper.java:68)
        	at org.springframework.data.mongodb.core.QueryOperations$UpdateContext.getMappedUpdate(QueryOperations.java:776)
        	at org.springframework.data.mongodb.core.MongoTemplate.doUpdate(MongoTemplate.java:1642)
        	at org.springframework.data.mongodb.core.MongoTemplate.updateMulti(MongoTemplate.java:1583)
    

    This blocks upgrades to Spring Boot 2.5.X. Hope the fix gets merged soon.

  14. jnaalisv commented on Jun 13, 2021

    @jnaalisv

    @IsNull Thanks for reporting this!

  15. added this to the 3.1.10 (2020.0.10) milestone on Jun 18, 2021
  16. removed
    status: feedback-provided
    on Jun 18, 2021
  17. added a commit that references this issue on May 20, 2024
    a1c1659
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

type: regression

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions