質問

I've got a sample project which uses Spring Data Neo4j's advanced mapping using aspectj. It's failing in a test with NullPointerException due to the entityState attribute being null at the time when the entity is being persisted.

I can also replicate this when the server itself is spun up and I execute:

curl -i -X POST -H "Content-Type:application/json" -d '{  "firstName" : "Test",  "lastName" : "Person" }' http://localhost:8080/people

The project is at https://github.com/dhallam/spring-data-neo4j-demo and the Travis build with the logs is at https://travis-ci.org/dhallam/spring-data-neo4j-demo/builds/22538972.

I'm not sure whether I'm missing something or there is a bug that would require me to raise a JIRA issue.

Any ideas? Many thanks in advance.

Edit 1:

Versions: Java v1.7; SDNeo4j v3.1.0.M1; SDRest v2.1.0.M1; Neo4j v2.0.1; Jetty v9.0.5.v20130815; AspectJ v1.7.4

Tried adding @JsonIgnoreProperties to the Person (@NodeEntity)from Michael's comment below and it's still failing. The bit of code that is failing is when I run:

Person p = new Person();
// setters ...
p.persist();

The persist() calls

public <T extends NodeBacked> T NodeBacked.persist() {
    return (T)this.entityState.persist();
}

but entityState is null.

役に立ちましたか?

解決

Figured it out. The Neo4jConfig class previously extended the Neo4jConfiguration class. With the introduction of aspects, that superclass needed to be updated to be Neo4jAspectConfiguration to provide the additional neo4jRelationshipBacking and neo4jNodeBacking beans.

I've updated the github reference project at https://github.com/dhallam/spring-data-neo4j-demo and the build is passing.

他のヒント

Which versions do you use?

You can use @JsonIgnore for the entityState attribute.

See: http://forum.spring.io/forum/spring-projects/data/nosql/110063-unable-to-convert-nodeentity-object-to-json-with-jackson

@JsonIgnoreProperties({"entityState", "nodeId", "persistentState", "relationshipTo", "template"})
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top