osmosis import to Postgis doesm't work

Hi there,

I’ve got a problem with the import of .osm files into a PostGIS database.
I think the database is set up correctly, I used the pgsql_simple_schema_0.6.sql schema from osmosis.
I also used the 900913.sql file.

When i try to import a file like this:
osmosis --read-xml file=“madagascar.osm” --write-apidb host=“localhost” database=“osm5” user=“postgres” password=“12345”

I get the following error message:

May 2, 2010 1:14:57 PM org.openstreetmap.osmosis.core.Osmosis run
INFO: Osmosis Version 0.35
May 2, 2010 1:14:57 PM org.java.plugin.registry.xml.ManifestParser
INFO: got SAX parser factory - org.apache.xerces.jaxp.SAXParserFactoryImpl@198a455
May 2, 2010 1:14:57 PM org.java.plugin.registry.xml.PluginRegistryImpl configure
INFO: configured, stopOnError=false, isValidating=true
May 2, 2010 1:14:57 PM org.java.plugin.registry.xml.PluginRegistryImpl register
INFO: plug-in and fragment descriptors registered - 1
May 2, 2010 1:14:57 PM org.java.plugin.standard.StandardPluginManager activatePlugin
INFO: plug-in started - org.openstreetmap.osmosis.core.plugin.Core@0.35.0
May 2, 2010 1:14:57 PM org.openstreetmap.osmosis.core.Osmosis run
INFO: Preparing pipeline.
May 2, 2010 1:14:57 PM org.openstreetmap.osmosis.core.Osmosis run
INFO: Launching pipeline execution.
May 2, 2010 1:14:57 PM org.openstreetmap.osmosis.core.Osmosis run
INFO: Pipeline executing, waiting for completion.
May 2, 2010 1:14:57 PM org.openstreetmap.osmosis.core.pipeline.common.ActiveTaskManager waitForCompletion
SEVERE: Thread for task 1-read-xml failed
org.openstreetmap.osmosis.core.OsmosisRuntimeException: Unable to create resultset.
at org.openstreetmap.osmosis.core.apidb.common.DatabaseContext.executeQuery(DatabaseContext.java:429)
at org.openstreetmap.osmosis.core.apidb.v0_6.impl.SchemaVersionValidator.validateDBVersion(SchemaVersionValidator.java:82)
at org.openstreetmap.osmosis.core.apidb.v0_6.impl.SchemaVersionValidator.validateVersion(SchemaVersionValidator.java:55)
at org.openstreetmap.osmosis.core.apidb.v0_6.ApidbWriter.initialize(ApidbWriter.java:288)
at org.openstreetmap.osmosis.core.apidb.v0_6.ApidbWriter.process(ApidbWriter.java:1046)
at org.openstreetmap.osmosis.core.xml.v0_6.impl.BoundElementProcessor.end(BoundElementProcessor.java:85)
at org.openstreetmap.osmosis.core.xml.v0_6.impl.OsmHandler.endElement(OsmHandler.java:107)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
at org.openstreetmap.osmosis.core.xml.v0_6.XmlReader.run(XmlReader.java:108)
at java.lang.Thread.run(Thread.java:636)
Caused by: org.postgresql.util.PSQLException: ERROR: relation “schema_migrations” does not exist
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1592)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1327)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:192)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:451)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:336)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:235)
at org.openstreetmap.osmosis.core.apidb.common.DatabaseContext.executeQuery(DatabaseContext.java:424)
… 20 more
May 2, 2010 1:14:57 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.waitForCompletion(Pipeline.java:146)
at org.openstreetmap.osmosis.core.Osmosis.run(Osmosis.java:85)
at org.openstreetmap.osmosis.core.Osmosis.main(Osmosis.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:329)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
at org.codehaus.classworlds.Launcher.main(Launcher.java:31)

I have no idea what to do now…
OS is Ubuntu 10.04, Postgres 8.4, Osmosis 0.35

I’am glad for every help

If you’re using the simple schema then you should use the --write-pgsql option not the api option (this latter requires a different SQL schema):

http://wiki.openstreetmap.org/wiki/Osmosis/Detailed_Usage#–write-pgsql_.28–wp.29

Dont know if that’s the be all and end all of it, but should definitely remove one block on the road.

Thanks, that worked for me.