我正在运行以下 java 代码(对此处发布的示例进行非常小的修改https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-java.html)并获得一个空指针例外。我看到顶点是在海王星中创建的,但驱动程序似乎对响应进行了轰炸。
我在这里做错了吗?有没有人成功地使用 Java 在 Neptune 中以编程方式创建顶点。
public class NeptuneMain {
public static void main(String[] args) {
Cluster.Builder builder = Cluster.build();
builder.addContactPoint("<enter cluster url here>");
builder.port(8182);
Cluster cluster = builder.create();
GraphTraversalSource g = EmptyGraph.instance().traversal().withRemote(DriverRemoteConnection.using(cluster));
GraphTraversal t = g.addV("Aspect");
t.forEachRemaining(
e -> System.out.println(e)
);
cluster.close();
}
}
堆栈跟踪是:
Exception in thread "main" java.util.concurrent.CompletionException: java.lang.NullPointerException
at java.util.concurrent.CompletableFuture.reportJoin(CompletableFuture.java:375)
at java.util.concurrent.CompletableFuture.join(CompletableFuture.java:1934)
at org.apache.tinkerpop.gremlin.driver.ResultSet.one(ResultSet.java:107)
at org.apache.tinkerpop.gremlin.driver.ResultSet$1.hasNext(ResultSet.java:159)
at org.apache.tinkerpop.gremlin.driver.ResultSet$1.next(ResultSet.java:166)
at org.apache.tinkerpop.gremlin.driver.ResultSet$1.next(ResultSet.java:153)
at org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteTraversal$TraverserIterator.next(DriverRemoteTraversal.java:142)
at