neo4j spatial osmimporter

10 views
Skip to first unread message

Sun Yuhan

unread,
Mar 12, 2017, 1:12:01 AM3/12/17
to Neo4j
I am currently using neo4j spatial extension. I want to load osm data into neo4j. I have two questions. One is about construct the batchinserter. The other one is osmimporter.

My code is as follows:

try
{
OSMImporter importer = new OSMImporter("test");\\\\\\\\\\\\\\\\\\\\\\\\\\\\ line1
importer.setCharset(Charset.forName("UTF-8"));\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\    2
Map<String, String> config = new HashMap<String, String>(); \\\\\\\\\\\\\\\\    3
config.put("dbms.pagecache.memory", "6g"); \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\    4
String db_path = "/home/yuhansun/Documents/GeoGraphMatchData/neo4j-community-3.1.1/data/databases/graph.db";\\\\\\\\\\\  5
BatchInserter batchInserter = BatchInserters.inserter(new File(db_path).getAbsoluteFile(), config);\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 6
importer.importFile(batchInserter, osm_filepath);\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 7
batchInserter.shutdown();
}

The first exception I get is in the line 5. I used to start the service of neo4j by using /neo4j start in command line. But I am sure it is stopped before I construct batchinserter. I delete the whole neo4j database and try to run the same code on a wholly empty neo4j database. This time it works. I am confused. What's the reason? How to use the batchinserter in version 3.1.1? I used batchinserter in version 2.2.3 by following the same way without getting any error. But in the latest version I get such exception.

Even though line 5 is executed successfully, I get exception on line 7. The file I used is the test file on the github website of neo4j spatial named with map.osm. But I get the following exception:

Importing with osm-writer: OSMBatchWriter: BatchInserter[EmbeddedBatchInserter[/home/yuhansun/Documents/GeoGraphMatchData/neo4j-community-3.1.1/data/databases/graph.db]]:IndexService[org.neo4j.index.impl.lucene.legacy.LuceneBatchInserterIndexProviderNewImpl@53bc1328]
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collections/MapUtils
at org.neo4j.gis.spatial.osm.OSMImporter$OSMBatchWriter.getUserNode(OSMImporter.java:1714)
at org.neo4j.gis.spatial.osm.OSMImporter$OSMBatchWriter.getChangesetNode(OSMImporter.java:1656)
at org.neo4j.gis.spatial.osm.OSMImporter$OSMBatchWriter.getChangesetNode(OSMImporter.java:1347)
at org.neo4j.gis.spatial.osm.OSMImporter$OSMWriter.createOSMNode(OSMImporter.java:641)
at org.neo4j.gis.spatial.osm.OSMImporter.importFile(OSMImporter.java:1914)
at org.neo4j.gis.spatial.osm.OSMImporter.importFile(OSMImporter.java:1765)
at osm.LoadData.LoadTest(LoadData.java:33)
at osm.LoadData.main(LoadData.java:19)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.MapUtils
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 8 more

Why do I get this and how can I fix it?

Reply all
Reply to author
Forward
0 new messages