读取JSON密码和Rest API Neo4j时出错

读取JSON密码和Rest API Neo4j时出错,neo4j,cypher,Neo4j,Cypher,我正试图使用neo4j-REST-graphdb-2.0.0-M06.jar通过java在restapi上执行Cypher查询。从 我使用的java代码是: RestAPI graphdb1 = new RestAPIFacade(dbpath); QueryEngine engine1 = new RestCypherQueryEngine(graphdb1); String cypherQuery= "match (X)-[:rel1]-(Y) where X:LABEL_X and Y:L

我正试图使用neo4j-REST-graphdb-2.0.0-M06.jar通过java在restapi上执行Cypher查询。从

我使用的java代码是:

RestAPI graphdb1 = new RestAPIFacade(dbpath);
QueryEngine engine1 = new RestCypherQueryEngine(graphdb1);
String cypherQuery= "match (X)-[:rel1]-(Y) where X:LABEL_X and Y:LABEL_Y return X.id,X.name";       
engine1.query(cypherQuery, Collections.EMPTY_MAP);
我得到一个例外:

Exception in thread "main" 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.ExecutingRestRequest.toMap(ExecutingRestRequest.java:212)
    at org.neo4j.rest.graphdb.ExecutingRestAPI.query(ExecutingRestAPI.java:544)
    at org.neo4j.rest.graphdb.ExecutingRestAPI.query(ExecutingRestAPI.java:564)
    at org.neo4j.rest.graphdb.RestAPIFacade.query(RestAPIFacade.java:234)
    at org.neo4j.rest.graphdb.query.RestCypherQueryEngine.query(RestCypherQueryEngine.java:50)
    at com.unmetric.graph.test.GraphConnectTest.testRestApi(GraphConnectTest.java:39)
    at com.unmetric.graph.test.GraphConnectTest.main(GraphConnectTest.java:26)
**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.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2718)
    at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1863)
    at org.neo4j.rest.graphdb.util.JsonHelper.readJson(JsonHelper.java:55)
    ... 10 more

我遇到了完全相同的问题。经过3个小时的调试,最终发现问题:

RestAPI graphdb1 = new RestAPIFacade(dbpath);
您不仅需要提供dbpath,还需要提供用户名和密码(默认用户名和密码都是neo4j)


如果在浏览器中执行查询,会发生什么?在neo4j web管理界面中?是的,我得到了结果。我在org.neo4j.rest.graphdb中看到了ExecutingRestApi.class中的代码:公共映射查询(字符串语句,映射参数){params=(params==null)?Collections.emptyMap():params;final RequestResult RequestResult=getRestRequest().post(“cypher”,MapUtil.Map(“query”,statement,“params”,params));return getRestRequest().toMap(requestResult);}这是导致问题的原因吗,方法签名应该改为CypherResult吗?这不意味着响应的实体流是空的或者已经被使用了吗?但这不应该发生,如果你得到一个响应,它应该包含一些实体,不是吗?服务器日志中有什么内容吗?
RestAPI graphdb1 = new RestAPIFacade(dbpath, "neo4j", "neo4j");