Hello, I am trying to get osmosis running. I am getting the following error:
Exception in thread “main” java.lang.NoClassDefFoundError: ///osmosis-0/31/lib/default/commons-logging-1/0/4/jar
Caused by: java.lang.ClassNotFoundException: …osmosis-0.31.lib.default.commons-logging-1.0.4.jar
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
Could not find the main class: …/osmosis-0.31/lib/default/commons-logging-1.0.4.jar. Program will exit.
I have confirmed that “…/osmosis-0.31/lib/default/” is in my classpath, which is where that jar file lives. I am unclear why I am getting this error. Can anyone help?
You on windows? I was just trying to get it working on windows. Had some classpath problems. I could be wrong but I suspect the bat file is broken at the moment. Most people are running osmosis on linux. I fixed it by fiddling with the classpath appearing at the bottom of osmosis.bat I think it doesn’t use your system classpath
Come to think of it, a NoClassDefFoundError should be mentioning the name of a class it can’t find, not the name of a jar file. This suggests that the java call being built up in the bin/osmosis script is formatted wrong. It’s must be looking at part of the classpath and interpreting that as the name of the main class to run.
…so yes. Basically something going wrong in your bin/osmosis startup script. Latest SVN version looks like this : http://svn.openstreetmap.org/applications/utils/osmosis/trunk/bin/osmosis (see how it builds up the java command down at the bottom?) But I don’t really know what the root cause would be.
Harry this is very helpful. I’m getting similar problems to others with windows. Error message is:
I’ve been assuming its something to do with CLASSPATH, but have always avoided learning anything about java as a matter of course: so am pig-ignorant about where most of the java internals live.
Any more advice (except that along the lines of virtual linux).
yeah I hit that error on windows. I think PluginLifecycleException just happens to be the first external class reference (from the jpf jar) it tries to resolve. It’s actually not finding any of the jar files which are in the lib/default directory. So try editing bin/osmosis.bat look down the bottom where it builds the classpath. Wherever it says %MYAPP_HOME%\lib\ it should say %MYAPP_HOME%\lib\default\ (the jar files are all in that ‘default’ subdirectory)
Actually I wanted to run osmosis via the ‘java’ command so ended up building the classpath “by hand”. This command (complete with big ugly classpath) should work on windows or linux, assuming you’re in the osmosis directory. Add whatever arguments you require at the end including full paths to read and write files.
Thanks again Harry. For some reason I thought it was looking for classes elsewhere in the standard Java distribution. Now to work out how to use osmosis with Postgres!
Osmosis should be started using the osmosis/bin/osmosis shell script, not by calling java -jar osmosis.jar [etc]…
I got the same problem when trying to start Osmosis ‘by hand’ , using the Osmosis shell script everything worked fine on Ubuntu. The same is valid for Windows → use the osmosis.bat file.
Is there somewhere a howto on running osmosis. Whatever I do it does not work anymore for me. About 5-6month ago running java -jar it ran smooth.
I get the same note be it running with osmosis.bat or with java -jar (I added all folders of osmosis to classpath). Windows 7 x64.
Here’s my failure notices:
D:\Garmin\Viewfinderpanoramas 3degrees>java -jar -Xmx1200M osmosis.jar --read-xml file="germany.osm" --bounding-polygon file="germany.poly" --write-xml file="germanysrtm.osm"
02.09.2009 16:20:12 com.bretth.osmosis.core.Osmosis run
INFO: Osmosis Version 0.30
02.09.2009 16:20:12 com.bretth.osmosis.core.Osmosis run
INFO: Preparing pipeline.
02.09.2009 16:20:12 com.bretth.osmosis.core.Osmosis run
INFO: Launching pipeline execution.
02.09.2009 16:20:12 com.bretth.osmosis.core.Osmosis run
INFO: Pipeline executing, waiting for completion.
02.09.2009 16:20:14 com.bretth.osmosis.core.pipeline.common.ActiveTaskManager waitForCompletion
SCHWERWIEGEND: Thread for task 1-read-xml failed
java.lang.NullPointerException
at java.util.Calendar.setTime(Unknown Source)
at com.bretth.osmosis.core.xml.common.DateFormatter.format(DateFormatter.java:44)
at com.bretth.osmosis.core.xml.common.XmlTimestampFormat.formatTimestamp(XmlTimestampFormat.java:43)
at com.bretth.osmosis.core.domain.common.SimpleTimestampContainer.getFormattedTimestamp(SimpleTimestampContainer.java:33)
at com.bretth.osmosis.core.domain.v0_5.Entity.getFormattedTimestamp(Entity.java:197)
at com.bretth.osmosis.core.xml.v0_5.impl.WayWriter.process(WayWriter.java:55)
at com.bretth.osmosis.core.xml.v0_5.impl.OsmWriter$SubElementWriter.process(OsmWriter.java:144)
at com.bretth.osmosis.core.container.v0_5.WayContainer.process(WayContainer.java:60)
at com.bretth.osmosis.core.xml.v0_5.impl.OsmWriter.process(OsmWriter.java:70)
at com.bretth.osmosis.core.xml.v0_5.XmlWriter.process(XmlWriter.java:49)
at com.bretth.osmosis.core.filter.v0_5.AreaFilter.emitFilteredWay(AreaFilter.java:187)
at com.bretth.osmosis.core.filter.v0_5.AreaFilter.process(AreaFilter.java:154)
at com.bretth.osmosis.core.container.v0_5.WayContainer.process(WayContainer.java:60)
at com.bretth.osmosis.core.filter.v0_5.AreaFilter.process(AreaFilter.java:82)
at com.bretth.osmosis.core.xml.v0_5.impl.WayElementProcessor.end(WayElementProcessor.java:103)
at com.bretth.osmosis.core.xml.v0_5.impl.OsmHandler.endElement(OsmHandler.java:109)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at com.bretth.osmosis.core.xml.v0_5.XmlReader.run(XmlReader.java:109)
at java.lang.Thread.run(Unknown Source)
02.09.2009 16:20:14 com.bretth.osmosis.core.Osmosis main
SCHWERWIEGEND: Execution aborted.
com.bretth.osmosis.core.OsmosisRuntimeException: One or more tasks failed.
at com.bretth.osmosis.core.pipeline.common.Pipeline.waitForCompletion(Pipeline.java:146)
at com.bretth.osmosis.core.Osmosis.run(Osmosis.java:85)
at com.bretth.osmosis.core.Osmosis.main(Osmosis.java:30)
And another error I have seen a few times:
D:\Garmin\Viewfinderpanoramas 3degrees>"D:\Garmin\Viewfinderpanoramas 3degrees\osmosis-0.30\bin\osmosis.bat" --read-xml file="germany.osm" --bounding-polygon file="germany.poly" --write-xml file="germanysrtm.osm"
****** B A T C H R E C U R S I O N exceeds STACK limits ******
Recursion Count=651, Stack Usage=90 percent
****** B A T C H PROCESSING IS A B O R T E D ******
OK… I had same problems on Windows, but I finally figured out you need to run osmosis within the root directory via bin\osmosis.bat, otherwise it doesn’t work
Can I just add that I had some problems with the classpath on Windows due to having spaces in my paths - the old “Documents and Settings” problem. To fix this I simply added quotation marks around all the classpaths, which fixed the issue.
I have a bit of a love hate relationship with java apps and osmosis is a fair example of why.
It would have been nice to use it as intended (I agree with Lambertus on this one), but after spending a couple of days banging head against wall I made the choice to use it as a portable(?) app.
If we cannot get it to work any other way, then this will get us out of trouble.
Osmosis.jar and all of its dependencies (important!!! – they’re in the source archive) were copied into a single folder called “osmosis”. Just lump 'em all together in one folder and is easier than the normal directory structure with osmosis at the top and the dependencies below it in lib/default. This folder gets copied to the working directory (ie where .osm to be processed is located) and then run:
I just ran into this today on Windows with osmosis v0.38.
The problem was caused in my case by the cd ... commands in <osmosis.bat> which will not work if you are located on a different drive from where %MYAPP_HOME% points to.
The fix was to add the ‘/d’ switch to all cd commands in the script to allow changing directories across drives.
If you are using e.g. osmosis v0.38 in <osmosis.bat> remove or comment out
IF EXIST "%ALLUSERSPROFILE%\osmosis.bat" CALL "%ALLUSERSPROFILE%\osmosis.bat"
and
IF EXIST "%USERPROFILE%\osmosis.bat" CALL "%USERPROFILE%\osmosis.bat"
It is quite likely that you already have <osmosis.bat> in those locations so you’ll end up with an infinite recursive call. I don’t quite understand what’s the purpose of those calls.
Alternatively you can delete your <osmosis.bat> copies in %ALLUSERPROFILE% and %USERPROFILE%.
Thank you very much for this information! I have been struggling with this issue myself. I really need to get this working for work. I am a driver for a nyc moving company, and I rely on OpenStreetMap to get where I’m going. I have been having a really hard time without it, so I really need to get it working soon. I will try your suggestions and see if this helps. I’ll let you know how it goes.