Code that tries to create a new node and add a property and label. The runtime exception is thrown when we try to add the label. The rollback is working fine though. It appears that the API is trying to get details for the resource that is not yet created and trying to parse the response.
try ( Transaction tx = db.beginTx() ) {
//create new user
Node userNode = db.createNode();
userNode.setProperty( "id", id );
userNode.addLabel(DynamicLabel.label("GuestUser")); //throws runtime exception
tx.success();
}
Stack trace
java.lang.RuntimeException: Error reading as JSON ''
at org.neo4j.rest.graphdb.util.JsonHelper.readJson(JsonHelper.java:57)
at org.neo4j.rest.graphdb.util.JsonHelper.jsonToSingleValue(JsonHelper.java:62)
at org.neo4j.rest.graphdb.RequestResult.toEntity(RequestResult.java:114)
at org.neo4j.rest.graphdb.RequestResult.toMap(RequestResult.java:120)
at org.neo4j.rest.graphdb.ExecutingRestAPI.getData(ExecutingRestAPI.java:501)
at org.neo4j.rest.graphdb.RestAPIFacade.getData(RestAPIFacade.java:179)
at org.neo4j.rest.graphdb.entity.RestEntity.getStructuralData(RestEntity.java:75)
at org.neo4j.rest.graphdb.entity.RestNode.labelsPath(RestNode.java:188)
at org.neo4j.rest.graphdb.entity.RestNode.addLabel(RestNode.java:147)
Caused by: java.io.EOFException: No content to map to Object due to end of input
at org.codehaus.jackson.map.ObjectMapper._initForReading(ObjectMapper.java:2775)
...
at org.neo4j.rest.graphdb.util.JsonHelper.readJson(JsonHelper.java:55)
... 43 more
The neo4j rest api throws runtime exception (error reading as JSON '') when trying to add a label.
My current set up
Code that tries to create a new node and add a property and label. The runtime exception is thrown when we try to add the label. The rollback is working fine though. It appears that the API is trying to get details for the resource that is not yet created and trying to parse the response.
try ( Transaction tx = db.beginTx() ) { //create new user Node userNode = db.createNode(); userNode.setProperty( "id", id ); userNode.addLabel(DynamicLabel.label("GuestUser")); //throws runtime exception tx.success(); } Stack trace
java.lang.RuntimeException: Error reading as JSON '' at org.neo4j.rest.graphdb.util.JsonHelper.readJson(JsonHelper.java:57) at org.neo4j.rest.graphdb.util.JsonHelper.jsonToSingleValue(JsonHelper.java:62) at org.neo4j.rest.graphdb.RequestResult.toEntity(RequestResult.java:114) at org.neo4j.rest.graphdb.RequestResult.toMap(RequestResult.java:120) at org.neo4j.rest.graphdb.ExecutingRestAPI.getData(ExecutingRestAPI.java:501) at org.neo4j.rest.graphdb.RestAPIFacade.getData(RestAPIFacade.java:179) at org.neo4j.rest.graphdb.entity.RestEntity.getStructuralData(RestEntity.java:75) at org.neo4j.rest.graphdb.entity.RestNode.labelsPath(RestNode.java:188) at org.neo4j.rest.graphdb.entity.RestNode.addLabel(RestNode.java:147)
Caused by: java.io.EOFException: No content to map to Object due to end of input at org.codehaus.jackson.map.ObjectMapper._initForReading(ObjectMapper.java:2775) ... at org.neo4j.rest.graphdb.util.JsonHelper.readJson(JsonHelper.java:55) ... 43 more
http://stackoverflow.com/questions/21169571/unable-to-add-label-using-neo4j-rest-api-error-reading-as-json