JDK 1.6 と Heroku を使用して、これらの Neo4j (1.9) エラーと RestApi を手伝ってくれる人はいますか。
このコードの目的は、Java で cypher と Neo4j を使用する機能をデモすることだけです。Heroku では RestAPI のみが機能することを理解しています。
package com.example;
import java.util.List;
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.helpers.collection.*;
import org.neo4j.rest.graphdb.RestAPI;
import org.neo4j.rest.graphdb.RestAPIFacade;
import org.neo4j.rest.graphdb.RestGraphDatabase;
import org.neo4j.rest.graphdb.query.RestCypherQueryEngine;
import org.neo4j.rest.graphdb.util.*;
import org.springframework.stereotype.Component;
import java.util.Map;
import com.example.IDatabaseConnector;
//import org.neo4j.rest.graphdb.RestGraphDatabase;
//import org.neo4j.
@Component
//public class Neo4jDatabaseConnector implements IDatabaseConnector {
public class Neo4jDatabaseConnector implements IDatabaseConnector{
Node aNode;
Node first;
Node second;
Relationship relation;
private static GraphDatabaseService GraphDb;
private static RestAPI restAPI;
Transaction txn;
private static enum RelTypes implements RelationshipType
{
KNOWS,
USAGE
}
public void showNode( )
{
// have to add code for cypher
RestCypherQueryEngine rcqe = new RestCypherQueryEngine(restAPI);
//Then just execute your cypher statements using rcqe.query().
// int length=0;
String countNodes = "START n=node(*) RETURN count(*)";
String createNodes = "CREATE (n {name: 'Trevor Oakley'})";
rcqe.query(createNodes, null);
// QueryResult <Map<String,Object>> result = rcqe.query(countNodes, null);
//for (Map<String, Object> row:result){
// length++;
//}
//System.out.println("length="+length);
// rcqe.query(countNodes, Map<String, Object> row:result);
// rcqe.query(countNodes, Map<String,Object>:result)
// rcqe.
/* ExecutionEngine engine = new ExecutionEngine(GraphDb);
int length=-1;
try{
ExecutionResult result = engine.execute("start n=node(*) return n");
if (result == null){
length = 0;
} else
{
for (@SuppressWarnings("unused")
Map<String, Object> row:result){
length++;
}
}
} catch (NullPointerException e) {
// _log.error(e.getMessage(),e);
length=-2;
}
System.out.println("len="+length);
*/
}
public Neo4jDatabaseConnector() {
//GraphDb=new GraphDatabaseFactory().newEmbeddedDatabase(Neo4j_DBPath);
}
public int createDBRest()
{
restAPI = new RestAPIFacade(System.getenv("NEO4J_URL"),
System.getenv("NEO4J_USERNAME"),
System.getenv("NEO4J_PASSWORD"));
try{
GraphDb = new RestGraphDatabase(restAPI);
}
catch (Exception e){
return 1;
}
return 0;
}
public int createDB(String dbLoc) {
System.out.println("db loc ="+dbLoc);
int error = 0;
try{
GraphDb=new GraphDatabaseFactory().newEmbeddedDatabase(dbLoc);
//GraphDb=new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(dbLoc);
System.out.println("db loc ="+dbLoc);
String stringDB = GraphDb.toString();
System.out.println("connection ="+stringDB);
}
catch (Exception e){
System.out.println("error - ");
error = 1;
}
return erro
r;
}
Problem accessing /hello. Reason:
Error reading as JSON ''
Caused by:
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:187)
at org.neo4j.rest.graphdb.ExecutingRestAPI.query(ExecutingRestAPI.java:475)
at org.neo4j.rest.graphdb.ExecutingRestAPI.query(ExecutingRestAPI.java:495)
at org.neo4j.rest.graphdb.RestAPIFacade.query(RestAPIFacade.java:233)
at org.neo4j.rest.graphdb.query.RestCypherQueryEngine.query(RestCypherQueryEngine.java:50)
at com.example.Neo4jDatabaseConnector.showNode(Neo4jDatabaseConnector.java:53)
at com.example.HelloServlet.doGet(HelloServlet.java:22)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:565)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:479)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:521)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1031)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:406)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:965)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
at org.eclipse.jetty.server.Server.handle(Server.java:349)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:449)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:910)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:634)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:76)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:609)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:45)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
at java.lang.Thread.run(Thread.java:679)
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)
... 34 more
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)
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:187)
at org.neo4j.rest.graphdb.ExecutingRestAPI.query(ExecutingRestAPI.java:475)
at org.neo4j.rest.graphdb.ExecutingRestAPI.query(ExecutingRestAPI.java:495)
at org.neo4j.rest.graphdb.RestAPIFacade.query(RestAPIFacade.java:233)
at org.neo4j.rest.graphdb.query.RestCypherQueryEngine.query(RestCypherQueryEngine.java:50)
at com.example.Neo4jDatabaseConnector.showNode(Neo4jDatabaseConnector.java:53)
at com.example.HelloServlet.doGet(HelloServlet.java:22)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:565)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:479)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:521)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1031)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:406)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:965)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
at org.eclipse.jetty.server.Server.handle(Server.java:349)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:449)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:910)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:634)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:76)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:609)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:45)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
at java.lang.Thread.run(Thread.java:679)