OpenStreetMap Forum

The Free Wiki World Map

You are not logged in.

#1 2009-07-20 07:26:21

Kyle Polich
Member
Registered: 2009-07-20
Posts: 3

Osmosis error

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?

Thanks!

Offline

#2 2009-07-22 00:45:37

Harry Wood
Member
From: London UK
Registered: 2007-05-29
Posts: 144
Website

Re: Osmosis error

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

Offline

#3 2009-07-22 04:18:44

Kyle Polich
Member
Registered: 2009-07-20
Posts: 3

Re: Osmosis error

Thank you for the suggestion Harry, but I am running this on Ubuntu, now Windows.

Offline

#4 2009-07-23 16:44:47

Harry Wood
Member
From: London UK
Registered: 2007-05-29
Posts: 144
Website

Re: Osmosis error

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/applicatio … in/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. 

Does it build OK if you do 'ant dist' ?

Offline

#5 2009-07-24 15:03:18

SK53
Member
Registered: 2009-01-11
Posts: 377

Re: Osmosis error

Harry this is very helpful. I'm getting similar problems to others with windows. Error message is:

java.lang.NoClassDefFoundError: org/java/plugin/PluginLifecycleException
        at org.openstreetmap.osmosis.core.Osmosis.run(Osmosis.java:73)
        at org.openstreetmap.osmosis.core.Osmosis.main(Osmosis.java:30)

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).

Offline

#6 2009-07-27 17:40:17

Harry Wood
Member
From: London UK
Registered: 2007-05-29
Posts: 144
Website

Re: Osmosis error

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)

But this has all been fixed in the version in subversion I think...    http://trac.openstreetmap.org/changeset … in%4015121    ....so really your best bet is probably to do a check out of the latest version. That goes for Kyle Polich too.

Offline

#7 2009-07-28 11:51:53

Harry Wood
Member
From: London UK
Registered: 2007-05-29
Posts: 144
Website

Re: Osmosis error

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.

java -Xmx1048m -cp "./osmosis.jar:./lib/default/aopalliance-1.0.jar:./lib/default/commons-pool-1.3.jar:./lib/default/postgresql-8.3-603.jdbc4.jar:./lib/default/spring-jdbc-2.5.6.SEC01.jar:./lib/default/bzip2-20090327.jar:./lib/default/jpf-1.5.jar:./lib/default/spring-beans-2.5.6.SEC01.jar:./lib/default/spring-tx-2.5.6.SEC01.jar:./lib/default/commons-dbcp-1.2.2.jar:./lib/default/mysql-connector-java-5.1.6.jar:./lib/default/spring-context-2.5.6.SEC01.jar:./lib/default/stax2-api-3.0.1.jar:./lib/default/commons-logging-1.1.1.jar:./lib/default/postgis-1.3.2.jar:./lib/default/spring-core-2.5.6.SEC01.jar:./lib/default/woodstox-core-lgpl-4.0.3.jar" org.openstreetmap.osmosis.core.Osmosis  --read-xml file=...etc etc (remaining command line arguements)

Offline

#8 2009-07-28 22:55:19

SK53
Member
Registered: 2009-01-11
Posts: 377

Re: Osmosis error

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!

Offline

#9 2009-07-29 01:09:26

SK53
Member
Registered: 2009-01-11
Posts: 377

Re: Osmosis error

There's another bug in the osmosis.bat file. This string:

%MYAPP_HOME%\lib\default\postgis_1.3.2.jar;

, should be

%MYAPP_HOME%\lib\default\postgis-1.3.2.jar;

, otherwise you get can't find geometry errors on the Postgres options, but the xml options work OK, and so no doubt do MySQL ones.

Offline

#10 2009-08-09 09:37:48

Lambertus
Administrator
From: Apeldoorn (NL)
Registered: 2007-03-17
Posts: 3,269
Website

Re: Osmosis error

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.


Mapping tools: Garmin GPSmap 60CSx, Giant Terrago 2002

Offline

#11 2009-09-02 15:46:08

extremecarver
Member
Registered: 2008-09-18
Posts: 404
Website

Re: Osmosis error

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      ******

Last edited by extremecarver (2009-09-02 15:48:58)


OSM Maps for Mtbikers and Hikers, OSM Karten fuer Mtbiker und Wanderer --> http://openmtbmap.org
OSM Maps for racing and casual cycling - für Rennradfahrer und Freizeitradfahrer --> http://www.velomap.org

Offline

#12 2009-09-02 15:57:05

extremecarver
Member
Registered: 2008-09-18
Posts: 404
Website

Re: Osmosis error

ok got it running by using the --enableDateParsing=no switch and downgrading to 0.29 which I found on my PC. Very strange anyhow....


OSM Maps for Mtbikers and Hikers, OSM Karten fuer Mtbiker und Wanderer --> http://openmtbmap.org
OSM Maps for racing and casual cycling - für Rennradfahrer und Freizeitradfahrer --> http://www.velomap.org

Offline

#13 2009-09-16 20:56:52

Breki
Member
Registered: 2009-05-08
Posts: 17

Re: Osmosis error

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

Offline

#14 2009-10-30 02:30:00

stev
Member
Registered: 2009-10-30
Posts: 1

Re: Osmosis error

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.

Offline

#15 2010-05-20 15:52:24

sSraH9o2
Member
Registered: 2010-05-16
Posts: 3

Re: Osmosis error

Hi everyone

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 <file>.osm to be processed is located) and then run:

java -Xmx1048m -cp "./osmosis/*" org.openstreetmap.osmosis.core.Osmosis <add arguments here>

Example:
Directories will look something like this:

$ ls /home/OSM/world/
australia.osm
australia.txt
osmosis    <<-- Directory
osmosis-notes.txt
planet-100512.osm.bz2.md5
planet-100512.osm.bz2

$ ls /home/OSM/world/osmosis
aopalliance-1.0.jar
bzip2.jar
commons-codec-1.4.jar
commons-compress-1.0.jar
2007 commons-dbcp-1.2.2.jar
2007 commons-logging-1.1.1.jar
commons-pool-1.3.jar
ivy-2.1.0.jar
jpf-1.5.jar
mysql-connector-java-5.1.10.jar
osmosis.jar
plexus-classworlds-2.2.2.jar
postgis-jdbc-1.3.3.jar
2008 postgresql-8.3-603.jdbc4.jar
spring-beans-2.5.6.SEC01.jar
spring-context-2.5.6.SEC01.jar
spring-core-2.5.6.SEC01.jar
2009 spring-jdbc-2.5.6.SEC01.jar
spring-tx-2.5.6.SEC01.jar
stax2-api-3.0.1.jar
woodstox-core-lgpl-4.0.3.jar
xercesImpl-2.9.1.jar

In this example the command is run from the /world directory.



And FWIW Harry's mess smile above is pretty much equal to this:

java -Xmx1048m -cp "./osmosis.jar:./lib/default/*" org.openstreetmap.osmosis.core.Osmosis  --read-xml file=...etc etc (remaining command line arguements)

The exception is where you'd want to run osmosis with different jar files.

Saves a pile of typing and typos.

Cheers

Last edited by sSraH9o2 (2010-05-20 16:35:54)

Offline

#16 2011-07-10 15:23:13

tilusnet
Member
Registered: 2009-09-05
Posts: 2

Re: Osmosis error

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.

Last edited by tilusnet (2011-07-10 15:23:43)

Offline

#17 2011-07-10 15:49:44

tilusnet
Member
Registered: 2009-09-05
Posts: 2

Re: Osmosis error

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      ******

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%.

Offline

#18 2011-12-29 16:10:50

Iesha
Member
Registered: 2011-12-29
Posts: 1

Re: Osmosis error

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.

Last edited by Iesha (2012-01-06 00:04:34)

Offline

Board footer

Powered by FluxBB