cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Error: Node model already contains property

I'm using Quarkus with Neo4j-OGM to store Maven-Data gathered within a Jenkins-Run (the maven-plugin gathers data sends it via REST to the Quarkus service, which writes to Neo4j).

Quarkus 1.10.3.Final
neo4j-ogm Driver 3.2.11
Neo4j DB 3.5.14

Lately I see exceptions like below in the log, and I was wondering how this comes. (Google didn't bring up anything.)
The error + log is from my PROD environment, and comes up again everytime I re-run the case. On the other hand it works in my DEV-environment, and other (similar) components work in PROD, too. (However, there are lots of such errors)

Any ideas, what the problem could be and how to fix it?

Many thanks in advance!

2021-06-09 00:19:20,711 ERROR [...MavenComponentService] (executor-thread-1) Error saving component xxx:xxx-services-model:3.1.0.34-snapshot: org.neo4j.ogm.exception.core.MappingException: Node model already contains property: groupId
	at org.neo4j.ogm.cypher.compiler.builders.node.DefaultNodeBuilder.addProperty(DefaultNodeBuilder.java:49)
	at org.neo4j.ogm.cypher.compiler.builders.node.DefaultNodeBuilder.addProperty(DefaultNodeBuilder.java:37)
	at java.util.HashMap.forEach(HashMap.java:1289)
	at org.neo4j.ogm.cypher.compiler.builders.node.AbstractPropertyContainerBuilder.addCompositeProperties(AbstractPropertyContainerBuilder.java:46)
	at org.neo4j.ogm.context.EntityGraphMapper.updateFieldsOnBuilder(EntityGraphMapper.java:716)
	at org.neo4j.ogm.context.EntityGraphMapper.updateNode(EntityGraphMapper.java:306)
	at org.neo4j.ogm.context.EntityGraphMapper.mapEntity(EntityGraphMapper.java:275)
	at org.neo4j.ogm.context.EntityGraphMapper.mapRelatedEntity(EntityGraphMapper.java:823)
	at org.neo4j.ogm.context.EntityGraphMapper.link(EntityGraphMapper.java:512)
	at org.neo4j.ogm.context.EntityGraphMapper.mapEntityReferences(EntityGraphMapper.java:436)
	at org.neo4j.ogm.context.EntityGraphMapper.mapEntity(EntityGraphMapper.java:280)
	at org.neo4j.ogm.context.EntityGraphMapper.map(EntityGraphMapper.java:168)
	at org.neo4j.ogm.session.delegates.SaveDelegate.lambda$save$0(SaveDelegate.java:84)
	at java.util.Collections$SingletonList.forEach(Collections.java:4824)
	at org.neo4j.ogm.session.delegates.SaveDelegate.save(SaveDelegate.java:82)
	at org.neo4j.ogm.session.Neo4jSession.save(Neo4jSession.java:485)
1 ACCEPTED SOLUTION

Finally fixed the bug.

Removed @Convert(NoPrefixPropertiesConverter.class) and replaced with @Properties(prefix = "aux", delimiter = ":")
This, and some other, smaller changes to be more standard-compliant.

Main issue with the NoPrefixPropertiesConverter was in the context of relations - Neo4j (or OGM) seems to update the related Node, when changing the relation (even when the node itself is not touched), and that somehow doesn't cope well with the above mentioned properties converter.

View solution in original post

4 REPLIES 4

It seems that the CompositeAttributeConverter you are using for a particular field returns a Map containing the groupId key. But this property is already defined on the node itself.
Without code this is of course just a wild guess I can make for now.

OK, I managed to download the database-files and debug locally.

It seems, Neo4j wants to save the entity n, which has a relation to a parent: (n:MavenComponent) -[:PARENT]-> (p:MavenComponent).
The error occurs when trying to save the related entities of n, which is: p.

The parent p already exists in the DB, and should be known within the session-context - I fetch such related nodes specifically to prevent updates on already known entities (= those found in DB).

I debugged it, and stoped at this line where Neo4j tries to map already existing properties to the parent node p:

at org.neo4j.ogm.context.EntityGraphMapper.updateNode(EntityGraphMapper.java:306)

At this breakpoint I can see the clash of existing node-properties and my additional properties - which are the same.

Now the weird stuff: when I manually delete the parent node p from the DB, and rerun my tests, there is no problem at all. The parent node p gets created again (because of the maven structure). And I can do several subsequent runs, without any problem!

I can even change properties - no effect.
However, when I change relations on the parent node (manually, or by code), the same error occours.

Any ideas why?

Some more context:

  • I'm using a custom property converter for additional properties, like that: @Convert(NoPrefixPropertiesConverter.class) private Map<String, String> properties = new HashMap<>();
  • I'm using a custom id, which is a string value (concatenated GAV values, Maven style)
  • I'm using an event-listener add/update a timestamp property onPreSave(), which I register like that: sessionFactory.register(new AddTimestampEventListener());

Thank you, @gerrit.meier, for your reply!

I had the same idea, so I activated debug logging in DEV where I could not find any suspicious property (and no error occured there).
So... I will try to get a grasp on the data in my Openshift Environment to debug it locally.

Finally fixed the bug.

Removed @Convert(NoPrefixPropertiesConverter.class) and replaced with @Properties(prefix = "aux", delimiter = ":")
This, and some other, smaller changes to be more standard-compliant.

Main issue with the NoPrefixPropertiesConverter was in the context of relations - Neo4j (or OGM) seems to update the related Node, when changing the relation (even when the node itself is not touched), and that somehow doesn't cope well with the above mentioned properties converter.