Search code examples
openstreetmap

Osmosis not working with mapfilewriter plugin


I've recently downloaded Osmosis to convert .osm.pbf files to .map files. I'm using Windows 7 for this application. I've downloaded the latest zip file from their system and placed the mapfilewriter jar files into the /lib/default/ folder. However, I keep receiving this error when I run this statement in the .bat file:

osmosis --read-pbf file=taiwanlatest.osm.pbf --mapfile-writer file=helloworld.map

Mar 19, 2013 7:34:49 PM org.openstreetmap.osmosis.core.Osmosis run
INFO: Osmosis Version 0.42
Mar 19, 2013 7:34:49 PM org.openstreetmap.osmosis.core.Osmosis run
INFO: Preparing pipeline.
Mar 19, 2013 7:34:50 PM org.mapsforge.map.writer.osmosis.MapFileWriterTask <init>
INFO: mapfile-writer version: mapsforge-map-writer-0.3.0
Mar 19, 2013 7:34:50 PM org.mapsforge.map.writer.osmosis.MapFileWriterTask <init>
INFO: mapfile format specification version: 3
Mar 19, 2013 7:34:50 PM org.openstreetmap.osmosis.core.Osmosis run
INFO: Launching pipeline execution.
Mar 19, 2013 7:34:50 PM org.openstreetmap.osmosis.core.Osmosis run
INFO: Pipeline executing, waiting for completion.
Mar 19, 2013 7:34:50 PM org.openstreetmap.osmosis.core.pipeline.common.ActiveTaskManager waitForCompletion
SEVERE: Thread for task 1-read-pbf failed
java.lang.AbstractMethodError: org.mapsforge.map.writer.osmosis.MapFileWriterTas
k.initialize(Ljava/util/Map;)V
        at crosby.binary.osmosis.OsmosisReader.run(OsmosisReader.java:43)
        at java.lang.Thread.run(Thread.java:722)

Mar 19, 2013 7:34:50 PM org.openstreetmap.osmosis.core.Osmosis main
SEVERE: Execution aborted.
org.openstreetmap.osmosis.core.OsmosisRuntimeException: One or more tasks failed
.
        at org.openstreetmap.osmosis.core.pipeline.common.Pipeline.waitForComple
tion(Pipeline.java:146)
        at org.openstreetmap.osmosis.core.Osmosis.run(Osmosis.java:92)
        at org.openstreetmap.osmosis.core.Osmosis.main(Osmosis.java:37)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Laun
cher.java:329)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:239)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
352)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:47)

I've read up and it seems that this occurs due to the osmosis itself, and that I have to use a lower version's osmosis. I've tried to use Osmosis version 0.40 and I've gotten this error when I run the .bat file:

Error: Could not find or load main class org.codehaus.classworlds.Launcher

Where exactly did I go wrong?


Solution

  • After much trial and error, I finally made it work by downloading Osmosis version 0.40.1 here.

    In addition, I've added 4 jar files in the /lib/default folder:

    1. mapsforge-map-writer-0.3.0-jar-with-dependencies.jar
    2. mapsforge-map-0.3.0-jar-with-dependencies.jar
    3. trove-3.0.3.zip
    4. jts-1.8.jar

    After which, i created a new conf file named "osmosis-plugins.conf" and added a line " org.mapsforge.map.writer.osmosis.MapFileWriterPluginLoader" in it.

    After doing these steps, Osmosis finally works (though I'm not sure if this is the most correct way of doing it).

    However, I still don't really understand why the latest version of Osmosis does not work.

    Hope this can help those who faced a similar problem as me!