Neo4j: APOC - Caused by: java.io.RuntimeException: Can't read url or key file (No such file or directory)
I’ve been using Neo4j’s APOC library to load some local JSON files this week, and ran into an interesting problem.
LOAD CSV tool assumes that any files you load locally are in the
import directory, so I’ve got into the habit of putting my data there.
Let’s check what I’m trying to import by opening the import directory:
What’s in there?
Just the one JSON file needs processing. If we want to import local files we need to add the following property to our Neo4j configuration file:
If you’re using the Neo4j Desktop, you can add this property via the 'Settings' tab:
Once we’ve done that we’ll need to restart the database so our new settings will be picked up:
Now let’s try to process our JSON file:
neo4j> CALL apoc.load.json("file:///dummy.json"); Failed to invoke procedure `apoc.load.json`: Caused by: java.lang.RuntimeException: Can't read url or key file:/dummy.json as json: /dummy.json (No such file or directory)
Hmm, that didn’t work as we expected - it seems to be trying to read the file from the root of the machine rather than from the
It turns out I hadn’t RTFM:
Let’s update our Neo4j configuration file to add the following property:
If we re-run our query we’ll see that it now finds and processes the file: