1
votes

Not sure what I am doing wrong, but with my set up even a basic cypher query using the neo4j Rest API is not working. I get a java.lang.RuntimeException: Error reading as JSON ''

My set up

<dependency> 
    <groupId>org.neo4j</groupId> 
    <artifactId>neo4j-rest-graphdb</artifactId> 
    <version>2.0.0-M06</version>
</dependency>
<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j</artifactId>
    <version>2.0.0</version>
</dependency>
<dependency>
    <groupId>org.neo4j.app</groupId>
    <artifactId>neo4j-server</artifactId>
    <version>2.0.0</version>
</dependency>

private GraphDatabaseService graphDb;
private RestCypherQueryEngine queryEngine;
System.setProperty("org.neo4j.rest.batch_transaction", "true");
graphDb = new RestGraphDatabase( "http://localhost:7474/db/data/" );
queryEngine = new RestCypherQueryEngine(((RestGraphDatabase)graphDb).getRestAPI());

StringBuilder query = new StringBuilder();
query.append("match (u { id:'").append(id).append("' }) return u");

QueryResult<Map<String,Object>> result = engine.query(query.toString(), null);
//the above statement throws the runtime exception with message "Error reading as JSON '' "

1
The variable "id" is most likely empty. Can you double check? Maybe add a hard coded value in your append statement, just for testing purposes?tstorms

1 Answers

0
votes

I just released 2.0.0 of java-rest-binding, so please give that a try.

M06 shouldn't really work with Neo4j 2.0.0 final.