我们正在尝试执行运行Neo4j查询的程序。
使用NetBeans,它可以成功执行。但是当我们使用cmd运行它时,会出现以下错误 -
C:\>java -jar "C:\Users\sourabh\Documents\NetBeansProjects\freeb2\dist\freeb2.ja
r"
org.neo4j.cypher.EntityNotFoundException: Node 1 not found
at org.neo4j.cypher.internal.spi.gdsimpl.GDSBackedQueryContext$$anon$1.g
etById(GDSBackedQueryContext.scala:80)
at org.neo4j.cypher.internal.spi.gdsimpl.GDSBackedQueryContext$$anon$1.g
etById(GDSBackedQueryContext.scala:48)
at org.neo4j.cypher.internal.executionplan.builders.NodeByIdBuilder$$ano
nfun$org$neo4j$cypher$internal$executionplan$builders$NodeByIdBuilder$$f$1$1.app
ly(NodeByIdBuilder.scala:41)
at org.neo4j.cypher.internal.executionplan.builders.NodeByIdBuilder$$ano
nfun$org$neo4j$cypher$internal$executionplan$builders$NodeByIdBuilder$$f$1$1.app
ly(NodeByIdBuilder.scala:41)
at org.neo4j.cypher.internal.executionplan.builders.GetGraphElements$.or
g$neo4j$cypher$internal$executionplan$builders$GetGraphElements$$castElement$1(G
etGraphElements.scala:30)
at org.neo4j.cypher.internal.executionplan.builders.GetGraphElements$$an
onfun$getElements$3.apply(GetGraphElements.scala:40)
at scala.collection.Iterator$$anon$11.next(Iterator.scala:328)
at scala.collection.Iterator$$anon$11.next(Iterator.scala:328)
at scala.collection.Iterator$$anon$13.next(Iterator.scala:372)
at org.neo4j.cypher.internal.ClosingIterator$$anonfun$next$1.apply(Closi
ngIterator.scala:44)
at org.neo4j.cypher.internal.ClosingIterator.failIfThrows(ClosingIterato
r.scala:86)
at org.neo4j.cypher.internal.ClosingIterator.next(ClosingIterator.scala:
43)
at org.neo4j.cypher.PipeExecutionResult.next(PipeExecutionResult.scala:1
59)
at org.neo4j.cypher.PipeExecutionResult.next(PipeExecutionResult.scala:3
3)
at scala.collection.Iterator$$anon$11.next(Iterator.scala:328)
at scala.collection.Iterator$$anon$11.next(Iterator.scala:328)
at scala.collection.convert.Wrappers$IteratorWrapper.next(Wrappers.scala
:30)
at org.neo4j.cypher.PipeExecutionResult$$anon$1.next(PipeExecutionResult
.scala:75)
at freeb2.Freeb2.main(Freeb2.java:308)
Exception in thread "main" org.neo4j.graphdb.TransactionFailureException: Unable
to commit transaction
at org.neo4j.kernel.TopLevelTransaction.finish(TopLevelTransaction.java:
137)
at freeb2.Freeb2.main(Freeb2.java:620)
Caused by: javax.transaction.RollbackException: Failed to commit, transaction ro
lledback
at org.neo4j.kernel.impl.transaction.TxManager.rollbackCommit(TxManager.
java:565)
at org.neo4j.kernel.impl.transaction.TxManager.commit(TxManager.java:349
)
at org.neo4j.kernel.impl.transaction.TransactionImpl.commit(TransactionI
mpl.java:134)
at org.neo4j.kernel.TopLevelTransaction.finish(TopLevelTransaction.java:
127)
... 1 more
这是我们的代码 -
public static void main(String[] args)
{
Transaction tx = graphDb.beginTx();
try
{
tx.success();
engine = new ExecutionEngine( graphDb );// HttpTransport httpTransport = new NetHttpTransport();
String x = "start root = node(1) return root";
result = engine.execute( x );
^^^^^ Error due to this line
我们基本上做的是,使用NetBeans构建程序,并使用在To run this application from the command line without Ant, try: ...
下生成的命令执行代码。
任何帮助都会受到赞赏。
答案 0 :(得分:1)
说什么, EntityNotFoundException:未找到节点1
您必须先在图表中插入数据,然后才能进行查询。
有关如何导入数据的示例,请参阅neo4j.org和Rik博客上的import page。
请通过Neo4j online course来解决密码问题(例如,建议不要使用node-id)
答案 1 :(得分:1)
这是问题评论部分中Jason C提到的DB_PATH问题
它是用绝对路径修正的。