解释 LOAD CSV 错误“无法加载外部资源…”
当运行一个 LOAD CSV Cypher 语句时,例如
LOAD CSV WITH HEADERS FROM "http://10.12.1.2/Neo4j/cities.csv" AS row WITH row create (c:cities {name:row.city});
无论是通过 bin/neo4j-shell 还是浏览器 https://:7474,这可能会导致以下错误
couldn't load the external resource at: http://10.12.1.2/Neo4j/cities.csv. See debug.log for more details, reference 8a28b268-948d-43fa-8d6d-b1afb0130276
并且 data/graph.db/messages.log (2.x) 或 $NEO4J_HOME/log/debug.log (3.x) 中将包含类似的堆栈跟踪
2016-05-11 13:50:32.508+0000 ERROR [o.n.b.v.r.i.ErrorReporter] Client triggered an unexpected error [ExternalResourceFailed]: Couldn't load the external resource at: http://10.12.1.2/Neo4j/cities.csv. See debug.log for more details, reference 8a28b268-948d-43fa-8d6d-b1afb0130276.
2016-05-11 13:50:32.508+0000 ERROR [o.n.b.v.r.i.ErrorReporter] Client triggered an unexpected error [ExternalResourceFailed]: Couldn't load the external resource at: http://10.12.1.2/Neo4j/cities.csv, reference 8a28b268-948d-43fa-8d6d-b1afb0130276. Couldn't load the external resource at: http://10.12.1.2/Neo4j/cities.csv
org.neo4j.kernel.impl.query.QueryExecutionKernelException: Couldn't load the external resource at: http://mvabl.com/Neo4j/languages.csv
at org.neo4j.cypher.internal.javacompat.ExecutionEngine.executeQuery(ExecutionEngine.java:69)
at org.neo4j.bolt.v1.runtime.internal.CypherStatementRunner.run(CypherStatementRunner.java:73)
at org.neo4j.bolt.v1.runtime.internal.StandardStateMachineSPI.run(StandardStateMachineSPI.java:110)
at org.neo4j.bolt.v1.runtime.internal.SessionStateMachine$State$2.runStatement(SessionStateMachine.java:122)
at org.neo4j.bolt.v1.runtime.internal.SessionStateMachine.run(SessionStateMachine.java:653)
at org.neo4j.bolt.v1.runtime.internal.concurrent.SessionWorkerFacade.lambda$run$3(SessionWorkerFacade.java:68)
at org.neo4j.bolt.v1.runtime.internal.concurrent.SessionWorker.execute(SessionWorker.java:116)
at org.neo4j.bolt.v1.runtime.internal.concurrent.SessionWorker.executeBatch(SessionWorker.java:102)
at org.neo4j.bolt.v1.runtime.internal.concurrent.SessionWorker.run(SessionWorker.java:82)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.neo4j.cypher.LoadExternalResourceException: Couldn't load the external resource at: http://10.12.1.2/Neo4j/cities.csv
at org.neo4j.cypher.internal.compatibility.exceptionHandlerFor3_0$.loadExternalResourceException(CompatibilityFor3_0.scala:84)
at org.neo4j.cypher.internal.compatibility.exceptionHandlerFor3_0$.loadExternalResourceException(CompatibilityFor3_0.scala:61)
at org.neo4j.cypher.internal.frontend.v3_0.LoadExternalResourceException.mapToPublic(CypherException.scala:110)
at org.neo4j.cypher.internal.compatibility.exceptionHandlerFor3_0$.runSafely(CompatibilityFor3_0.scala:122)
at org.neo4j.cypher.internal.compatibility.CompatibilityFor3_0$ExecutionPlanWrapper.run(CompatibilityFor3_0.scala:199)
at org.neo4j.cypher.internal.PreparedPlanExecution.execute(PreparedPlanExecution.scala:27)
at org.neo4j.cypher.internal.ExecutionEngine.execute(ExecutionEngine.scala:111)
at org.neo4j.cypher.internal.javacompat.ExecutionEngine.executeQuery(ExecutionEngine.java:65)
... 9 more
Caused by: org.neo4j.cypher.internal.frontend.v3_0.LoadExternalResourceException
at org.neo4j.cypher.internal.compiler.v3_0.spi.CSVResources.openStream(CSVResources.scala:117)
at org.neo4j.cypher.internal.compiler.v3_0.spi.CSVResources.getCsvIterator(CSVResources.scala:55)
at org.neo4j.cypher.internal.compiler.v3_0.pipes.LoadCSVPipe$$anonfun$internalCreateResults$1.apply(LoadCSVPipe.scala:108)
at org.neo4j.cypher.internal.compiler.v3_0.pipes.LoadCSVPipe$$anonfun$internalCreateResults$1.apply(LoadCSVPipe.scala:103)
at scala.collection.Iterator$$anon$12.nextCur(Iterator.scala:434)
at scala.collection.Iterator$$anon$12.hasNext(Iterator.scala:440)
at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:408)
at org.neo4j.cypher.internal.compiler.v3_0.pipes.EmptyResultPipe.internalCreateResults(EmptyResultPipe.scala:31)
at org.neo4j.cypher.internal.compiler.v3_0.pipes.PipeWithSource.createResults(Pipe.scala:126)
at org.neo4j.cypher.internal.compiler.v3_0.pipes.PipeWithSource.createResults(Pipe.scala:123)
at org.neo4j.cypher.internal.compiler.v3_0.executionplan.DefaultExecutionResultBuilderFactory$ExecutionWorkflowBuilder.createResults(DefaultExecutionResultBuilderFactory.scala:94)
at org.neo4j.cypher.internal.compiler.v3_0.executionplan.DefaultExecutionResultBuilderFactory$ExecutionWorkflowBuilder.build(DefaultExecutionResultBuilderFactory.scala:64)
at org.neo4j.cypher.internal.compiler.v3_0.executionplan.InterpretedExecutionPlanBuilder$$anonfun$getExecutionPlanFunction$1.apply(ExecutionPlanBuilder.scala:164)
at org.neo4j.cypher.internal.compiler.v3_0.executionplan.InterpretedExecutionPlanBuilder$$anonfun$getExecutionPlanFunction$1.apply(ExecutionPlanBuilder.scala:148)
at org.neo4j.cypher.internal.compiler.v3_0.executionplan.InterpretedExecutionPlanBuilder$$anon$1.run(ExecutionPlanBuilder.scala:123)
at org.neo4j.cypher.internal.compatibility.CompatibilityFor3_0$ExecutionPlanWrapper$$anonfun$run$1.apply(CompatibilityFor3_0.scala:200)
at org.neo4j.cypher.internal.compatibility.CompatibilityFor3_0$ExecutionPlanWrapper$$anonfun$run$1.apply(CompatibilityFor3_0.scala:200)
at org.neo4j.cypher.internal.compatibility.exceptionHandlerFor3_0$.runSafely(CompatibilityFor3_0.scala:117)
... 13 more
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: http://10.12.1.2/Neo4j/cities.csv
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1840)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
at org.neo4j.cypher.internal.compiler.v3_0.spi.CSVResources.openStream(CSVResources.scala:109)
... 30 more
从堆栈跟踪中可以看到对
Server returned HTTP response code: 403 for URL: http://10.12.1.2/Neo4j/cities.csv
的引用表明 WebServer 在 10.12.1.2 接收到了请求,但返回了状态码 403(权限被拒绝)。
当请求提交给 WebServer 时,该请求的用户代理被定义为 "Java/1.8.0_91"。以下是 Apache WebServer 通用日志格式中该请求的单行日志记录。最后一个字段表示请求的用户代理。
192.168.1.176 - - [16/May/2016:08:34:15 -0400] "GET /Neo4j/cities.csv HTTP/1.1" 404 511 "-" "Java/1.8.0_91"
在上述情况下,WebServer 明确阻止了所有用户代理为 "Java/1.8.0_91" 的请求。解决此问题后,LOAD CSV 命令就成功了。
本页是否有帮助?