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.

When calling save on node entity causes stackoverflow error

Hi.
I am working on implementing a simple social media user follow functionality. However, when I add a new follow relation and call save on the node entity it causes a stack overflow error.

I am relative new to neo4j so i am not sure what exactly is causing the issue. I think it might be because neo4j tries to save all the reachable node.

This is a sample user model

@Node("User")
public class GraphUser {
    @Id
    private String userId;
    private String email;
    private String username;
    private String profilePicture
    private boolean privateProfile = false;

    @JsonIgnore
    @Relationship(type = "FOLLOWS")
    private List<FollowsRelation> followsList;
}

This is the relation model

@RelationshipProperties
public class FollowsRelation {
    @Id
    @GeneratedValue
    private Long id;

    private boolean status = true;

    private long createdTime;

    @TargetNode
    @JsonIgnore
    private GraphUser endNode;
}
java.lang.StackOverflowError: null
	at java.nio.CharBuffer.<init>(CharBuffer.java:281)
	at java.nio.HeapCharBuffer.<init>(HeapCharBuffer.java:70)
	at java.nio.CharBuffer.wrap(CharBuffer.java:373)
	at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:265)
	at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:125)
	at java.io.OutputStreamWriter.write(OutputStreamWriter.java:207)
	at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:129)
	at java.io.PrintStream.write(PrintStream.java:526)
	at java.io.PrintStream.print(PrintStream.java:669)
	at java.io.PrintStream.println(PrintStream.java:823)
	at java.lang.Throwable$WrappedPrintStream.println(Throwable.java:748)
	at java.lang.Throwable.printStackTrace(Throwable.java:655)
	at java.lang.Throwable.printStackTrace(Throwable.java:643)
	at java.lang.Throwable.printStackTrace(Throwable.java:634)
	at org.neo4j.cypherdsl.core.internal.ReflectiveVisitor.lambda$executeConcreteMethodIn$0(ReflectiveVisitor.java:125)
	at java.util.Optional.ifPresent(Optional.java:159)
	at org.neo4j.cypherdsl.core.internal.ReflectiveVisitor.executeConcreteMethodIn(ReflectiveVisitor.java:121)
	at org.neo4j.cypherdsl.core.internal.ReflectiveVisitor.enter(ReflectiveVisitor.java:104)
	at org.neo4j.cypherdsl.core.ast.Visitable.accept(Visitable.java:51)
	at org.neo4j.cypherdsl.core.NodeBase.lambda$accept$1(NodeBase.java:159)
	at java.util.ArrayList.forEach(ArrayList.java:1249)
	at org.neo4j.cypherdsl.core.NodeBase.accept(NodeBase.java:159)
	at org.neo4j.cypherdsl.core.ast.TypedSubtree.lambda$accept$0(TypedSubtree.java:71)
	at java.util.ArrayList.forEach(ArrayList.java:1249)
	at org.neo4j.cypherdsl.core.ast.TypedSubtree.accept(TypedSubtree.java:71)
	at org.neo4j.cypherdsl.core.Match.accept(Match.java:71)
	at org.neo4j.cypherdsl.core.MultiPartElement.lambda$accept$0(MultiPartElement.java:53)
	at java.util.ArrayList.forEach(ArrayList.java:1249)
	at org.neo4j.cypherdsl.core.MultiPartElement.accept(MultiPartElement.java:53)
	at org.neo4j.cypherdsl.core.MultiPartQuery.lambda$accept$0(MultiPartQuery.java:52)
	at java.util.ArrayList.forEach(ArrayList.java:1249)
	at org.neo4j.cypherdsl.core.MultiPartQuery.accept(MultiPartQuery.java:52)
	at org.neo4j.cypherdsl.core.renderer.ConfigurableRenderer.render(ConfigurableRenderer.java:83)
	at org.springframework.data.neo4j.core.Neo4jTemplate.lambda$queryRelatedNode$25(Neo4jTemplate.java:743)
	at org.springframework.data.neo4j.core.DefaultNeo4jClient$RunnableStatement.runWith(DefaultNeo4jClient.java:157)
	at org.springframework.data.neo4j.core.DefaultNeo4jClient$DefaultRecordFetchSpec.one(DefaultNeo4jClient.java:303)
	at org.springframework.data.neo4j.core.Neo4jTemplate.queryRelatedNode(Neo4jTemplate.java:749)
	at org.springframework.data.neo4j.core.Neo4jTemplate.lambda$processNestedRelations$24(Neo4jTemplate.java:679)
	at org.springframework.data.mapping.model.BasicPersistentEntity.doWithAssociations(BasicPersistentEntity.java:387)
	at org.springframework.data.neo4j.core.Neo4jTemplate.processNestedRelations(Neo4jTemplate.java:597)
	at org.springframework.data.neo4j.core.Neo4jTemplate.lambda$processNestedRelations$24(Neo4jTemplate.java:718)
	at org.springframework.data.mapping.model.BasicPersistentEntity.doWithAssociations(BasicPersistentEntity.java:387)
	at org.springframework.data.neo4j.core.Neo4jTemplate.processNestedRelations(Neo4jTemplate.java:597)
	at org.springframework.data.neo4j.core.Neo4jTemplate.lambda$processNestedRelations$24(Neo4jTemplate.java:718)
	at org.springframework.data.mapping.model.BasicPersistentEntity.doWithAssociations(BasicPersistentEntity.java:387)
	at org.springframework.data.neo4j.core.Neo4jTemplate.processNestedRelations(Neo4jTemplate.java:597)
	at org.springframework.data.neo4j.core.Neo4jTemplate.lambda$processNestedRelations$24(Neo4jTemplate.java:718)
	at org.springframework.data.mapping.model.BasicPersistentEntity.doWithAssociations(BasicPersistentEntity.java:387)
	at org.springframework.data.neo4j.core.Neo4jTemplate.processNestedRelations(Neo4jTemplate.java:597)
	at org.springframework.data.neo4j.core.Neo4jTemplate.lambda$processNestedRelations$24(Neo4jTemplate.java:718)
	at org.springframework.data.mapping.model.BasicPersistentEntity.doWithAssociations(BasicPersistentEntity.java:387)
	at org.springframework.data.neo4j.core.Neo4jTemplate.processNestedRelations(Neo4jTemplate.java:597)
	at org.springframework.data.neo4j.core.Neo4jTemplate.lambda$processNestedRelations$24(Neo4jTemplate.java:718)
	at org.springframework.data.mapping.model.BasicPersistentEntity.doWithAssociations(BasicPersistentEntity.java:387)
	at org.springframework.data.neo4j.core.Neo4jTemplate.processNestedRelations(Neo4jTemplate.java:597)
	at org.springframework.data.neo4j.core.Neo4jTemplate.lambda$processNestedRelations$24(Neo4jTemplate.java:718)
	at org.springframework.data.mapping.model.BasicPersistentEntity.doWithAssociations(BasicPersistentEntity.java:387)
	at org.springframework.data.neo4j.core.Neo4jTemplate.processNestedRelations(Neo4jTemplate.java:597)
	at org.springframework.data.neo4j.core.Neo4jTemplate.lambda$processNestedRelations$24(Neo4jTemplate.java:718)
	at org.springframework.data.mapping.model.BasicPersistentEntity.doWithAssociations(BasicPersistentEntity.java:387)
	at org.springframework.data.neo4j.core.Neo4jTemplate.processNestedRelations(Neo4jTemplate.java:597)
	at org.springframework.data.neo4j.core.Neo4jTemplate.lambda$processNestedRelations$24(Neo4jTemplate.java:718)
	at org.springframework.data.mapping.model.BasicPersistentEntity.doWithAssociations(BasicPersistentEntity.java:387)
	at org.springframework.data.neo4j.core.Neo4jTemplate.processNestedRelations(Neo4jTemplate.java:597)
	at org.springframework.data.neo4j.core.Neo4jTemplate.lambda$processNestedRelations$24(Neo4jTemplate.java:718)
	at org.springframework.data.mapping.model.BasicPersistentEntity.doWithAssociations(BasicPersistentEntity.java:387)
	at org.springframework.data.neo4j.core.Neo4jTemplate.processNestedRelations(Neo4jTemplate.java:597)

I will also attach the logs from neo4j as well neo4j-logs.txt (164.4 KB)

1 ACCEPTED SOLUTION

Hopefully you could find a solution to your problem already. Otherwise it would be helpful to see your persistence code and the versions you are using.
If you haven't tried it out yet, please use the latest version SDN, 6.1.4.

View solution in original post

2 REPLIES 2

Hopefully you could find a solution to your problem already. Otherwise it would be helpful to see your persistence code and the versions you are using.
If you haven't tried it out yet, please use the latest version SDN, 6.1.4.

Hi there
I am sorry I was not able to get back to you sooner. I was using SDN version 6.1.0. as per your suggestion, I updated the SDN to the latest version and the issue has been resolved. Thank you for your help