neo4j-contrib / java-rest-binding

Java Bindings for the Neo4J Server REST API, providing an implementation of GraphDatabaseService
Other
120 stars 72 forks source link

Unable to add label using Neo4j Rest API - Error reading as JSON '' #62

Closed saransna closed 10 years ago

saransna commented 10 years ago

The neo4j rest api throws runtime exception (error reading as JSON '') when trying to add a label.

My current set up

org.neo4j neo4j-rest-graphdb 2.0.0 org.neo4j neo4j 2.0.0 org.neo4j.app neo4j-server 2.0.0

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