Encountering MappingException After Upgrade

Hi All,
We have recently upgraded our system, transitioning from the existing version to the upgraded one. Following the upgrade, we encountered the following error during object mapping

Spring boot 2.5.1 to 3.2.4
Java 1.8 to Java 17
neo4j-community-3.5.12-windows to neo4j-community-4.4.31-windows
pom.xml
< dependency>
< groupId>org.springframework.boot< /groupId>
< artifactId>spring-boot-starter-data-neo4j< /artifactId>
< /dependency >
< !--
https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa -- >
< !-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-neo4j -- >
< dependency>
< groupId>org.springframework.data< /groupId>
< artifactId>spring-data-neo4j< /artifactId>
< version>7.2.5< /version>

< dependency >
< groupId>org.neo4j.driver< /groupId>
< artifactId>neo4j-java-driver< /artifactId>
< version>5.19.0< /version>
< /dependency>

Error:

org.springframework.data.mapping.MappingException: Error mapping Record<{sn: node<85711>, sr: [relationship<1837244>, relationship<1837245>, relationship<1837246>, relationship<1837247>, relationship<1837240>, relationship<1837241>, relationship<1837242>, relationship<1837243>, relationship<1837236>, relationship<1837237>, relationship<1837238>, node<98969>, node<85657>, node<98968>, node<85656>, node<85659>, node<98970>, node<85658>, node<98973>, node<85661>, node<6813>, node<85660>, node<85663>, node<98974>, node<85662>, node<98977>, node<85665>, node<523942>, node<98976>, node<85664>, node<98979>, node<85667>, node<523940>, node<98978>, node<85666>, node<85669>, node<98980>, node<85668>, node<98983>, node<85671>, node<98982>, node<85670>, node<85673>, node<85672>, node<85675>, node<85674>, node<85677>, node<85676>, node<85679>, node<85678>, node<85681>, node<85680>, node<85683>, node<523956>, node<85682>, node<98997>, node<85685>, node<85684>, node<85687>, node<85686>, node<99001>, node<85689>, node<99000>, node<85688>, node<85691>, node<99002>, node<85690>, node<99005>, node<85693>, node<85692>, node<99007>, node<85695>, node<99006>, node<85694>, node<99009>, node<85697>, node<99008>, node<85696>, node<85699>, node<99010>, node<85698>, node<85701>, node<85700>, node<85703>, node<85702>, node<99017>, node<85705>, node<85704>, node<99019>, node<85707>, node<99018>, node<85706>, node<99021>, node<85709>, node<99020>, node<85708>, node<85711>, node<85710>, node<99022>, node<85713>, node<85712>, node<85714>, node<99029>, node<85717>, node<85716>, node<85719>, node<99031>, node<82647>, node<85718>, node<99030>, node<85721>, node<99033>, node<85720>,, node<679752>,..... org.springframework.data.neo4j.core.mapping.DefaultNeo4jEntityConverter.read(DefaultNeo4jEntityConverter.java:123)

at org.springframework.data.neo4j.core.mapping.DefaultNeo4jEntityConverter.read(DefaultNeo4jEntityConverter.java:71)
at org.springframework.data.neo4j.core.mapping.Schema.lambda$getRequiredMappingFunctionFor$0(Schema.java:96)
at org.springframework.data.neo4j.core.PreparedQuery$AggregatingMappingFunction.apply(PreparedQuery.java:246)
at org.springframework.data.neo4j.core.PreparedQuery$AggregatingMappingFunction.apply(PreparedQuery.java:158)
at org.springframework.data.neo4j.core.DefaultNeo4jClient$DefaultRecordFetchSpec.one(DefaultNeo4jClient.java:444)
at java.base/java.util.Optional.flatMap(Optional.java:289)
at org.springframework.data.neo4j.core.Neo4jTemplate$DefaultExecutableQuery.lambda$getSingleResult$3(Neo4jTemplate.java:1194)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
at org.springframework.data.neo4j.core.Neo4jTemplate$DefaultExecutableQuery.getSingleResult(Neo4jTemplate.java:1192)
at org.springframework.data.neo4j.core.Neo4jTemplate.lambda$findById$12(Neo4jTemplate.java:335)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
at org.springframework.data.neo4j.core.Neo4jTemplate.findById(Neo4jTemplate.java:329)
at org.springframework.data.neo4j.repository.support.SimpleNeo4jRepository.findById(SimpleNeo4jRepository.java:71)
at jdk.internal.reflect.GeneratedMethodAccessor90.invoke(Unknown Source)

I would really like to help you, but the stack trace is missing the cause.
The top of the message is the outcome, the MappingException. There should be a root cause after the mass of nodes and relationships.

Hi @gerrit.meier Thank you for your reply.
But above mentioned pom and upgrade low to high mapping, configuration is it correct?

Also, we are using @Node, @Relationship, and @Property annotation so is it also correct with our configuration or do we need to change something?

Hi @gerrit.meier
Please refer to the attached stack trace error file.

error.txt (575.7 KB)

The upgrade looks ok.
I assume that you want to opt-in to the newest SDN and Driver version (with an 1 patch version older Spring Boot version), that's why you are declaring them explicitly, right?

It seems like something in your stack swallows the root cause of the exception.
In other cases the stack trace looks like this (taken from another report):

org.springframework.data.mapping.MappingException: Error mapping Record<{fooEntity: {name: "foo1", id: "ce382ea8-0a23-4bbb-9867-7d114b75bb75", __elementId__: 63, __nodeLabels__: ["FooEntity"]}}>

	at org.springframework.data.neo4j.core.mapping.DefaultNeo4jEntityConverter.read(DefaultNeo4jEntityConverter.java:123)
	at org.springframework.data.neo4j.core.mapping.DefaultNeo4jEntityConverter.read(DefaultNeo4jEntityConverter.java:71)
	at org.springframework.data.neo4j.core.mapping.Schema.lambda$getRequiredMappingFunctionFor$0(Schema.java:96)
	at org.springframework.data.neo4j.core.PreparedQuery$AggregatingMappingFunction.apply(PreparedQuery.java:246)
	at org.springframework.data.neo4j.core.PreparedQuery$AggregatingMappingFunction.apply(PreparedQuery.java:158)
...
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:220)
	at jdk.proxy2/jdk.proxy2.$Proxy67.findById(Unknown Source)
	at com.example.neo4jissue.one.FooTest.save_and_retrieve_test(FooTest.java:17)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.lang.IllegalStateException: Required property null not found for class com.example.neo4jissue.one.FooEntity
	at org.springframework.data.mapping.PersistentEntity.getRequiredPersistentProperty(PersistentEntity.java:190)
	at org.springframework.data.neo4j.core.mapping.DefaultNeo4jEntityConverter$1.getParameterValue(DefaultNeo4jEntityConverter.java:460)
	at ...

where the important bit for me would be Caused by...

Yes, we need to upgrade to the latest version of Neo4j, which is 4.4.32.
The current version, neo4j-community-3.5.12-windows, is likely not compatible with Spring Boot 3.2.4. We have many entities and relationship entities in our application.