Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

osmosis 0.45 update failing on "PSQLException: Can't infer the SQL type to use for an instance of java.util.HashMap" #5405

Open
openstreetmap-trac opened this issue Jul 23, 2021 · 10 comments

Comments

@openstreetmap-trac
Copy link

Reporter: Jocelyn
[Submitted to the original trac issue database at 9.49am, Wednesday, 15th June 2016]

Hi,

I'm getting the following failure when running:

osmosis-0.45/bin/osmosis --read-xml-change change-2016-06-16-21:49.osc.gz --write-pgsql-change database="$DATABASE" user="$USER" password="$PASS"
SEVERE: Thread for task 1-read-xml-change failed
org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [UPDATE nodes SET id = ?, version = ?, user_id = ?, tstamp = ?, changeset_id = ?, tags = ?, geom = ? WHERE id = ?]; nested exception is org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of java.util.HashMap. Use setObject() with an explicit Types value to specify the type to use.
	at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:99)
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:645)
	at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:866)
	at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:890)
	at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.update(NamedParameterJdbcTemplate.java:287)
	at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.update(NamedParameterJdbcTemplate.java:292)
	at org.openstreetmap.osmosis.pgsnapshot.v0_6.impl.EntityDao.modifyEntity(EntityDao.java:132)
	at org.openstreetmap.osmosis.pgsnapshot.v0_6.impl.NodeDao.modifyEntity(NodeDao.java:65)
	at org.openstreetmap.osmosis.pgsnapshot.v0_6.impl.ChangeWriter.write(ChangeWriter.java:126)
	at org.openstreetmap.osmosis.pgsnapshot.v0_6.impl.ActionChangeWriter.process(ActionChangeWriter.java:54)
	at org.openstreetmap.osmosis.core.container.v0_6.NodeContainer.process(NodeContainer.java:58)
	at org.openstreetmap.osmosis.pgsnapshot.v0_6.PostgreSqlChangeWriter.process(PostgreSqlChangeWriter.java:101)
	at org.openstreetmap.osmosis.xml.v0_6.impl.ChangeSourceElementProcessor$ChangeSinkAdapter.process(ChangeSourceElementProcessor.java:144)
	at org.openstreetmap.osmosis.xml.v0_6.impl.NodeElementProcessor.end(NodeElementProcessor.java:139)
	at org.openstreetmap.osmosis.xml.v0_6.impl.OsmChangeHandler.endElement(OsmChangeHandler.java:94)

I'm not sure if it is failing because of the change file - I can join it if you need it.

I'm on Debian Jessie, with openjdk 8, and postgresql 9.1.

Could this bug be linked to #5406 ?

@openstreetmap-trac
Copy link
Author

Author: Jocelyn
[Added to the original trac issue at 9.07pm, Thursday, 16th June 2016]

I've found that it is failing with this short change file:

<?xml version='1.0' encoding='UTF-8'?>
<osmChange version="0.6" generator="Osmosis 0.45">
  <modify>
    <node id="137492" version="17" timestamp="2016-05-27T12:12:33Z" uid="75260" user="RoPP" changeset="39602680" lat="45.1975444" lon="5.7851806"/>
  </modify>
</osmChange>

I've tried on another machine, a Debian Jessie using openjdk 8 and postgresql 9.4, with only this node in database, but it doesn't fail.

@openstreetmap-trac
Copy link
Author

Author: brett[at]bretth.com
[Added to the original trac issue at 12.34pm, Tuesday, 21st June 2016]

Hmm, it does seem related to #5406. Thanks for the sample change file. I'll test it out as soon as I can.

@openstreetmap-trac
Copy link
Author

Author: brett[at]bretth.com
[Added to the original trac issue at 12.59pm, Tuesday, 21st June 2016]

I've tried that test file on fedora 21 running postgres 9.3.9 and it works. Perhaps this is postgres version related.

One difference between 0.44.1 and 0.45 is the postgres JDBC driver version. Are you able to try recompiling with the older postgres JDBC driver?

Modify gradle.properties and modify the following line:

dependencyVersionPostgreSql=9.4-1204-jdbc4

to be

dependencyVersionPostgreSql=9.4-1201-jdbc4

Then recompile (i.e. ./gradlew assemble).

@openstreetmap-trac
Copy link
Author

Author: Jocelyn
[Added to the original trac issue at 8.46pm, Wednesday, 29th June 2016]

I've just tried with your change, and it still fails:

INFO: Osmosis Version 0.45-41-gf840f6f-dirty-SNAPSHOT
SEVERE: Thread for task 1-read-xml-change failed
org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [UPDATE nodes SET id = ?, version = ?, user_id = ?, tstamp = ?, changeset_id = ?, tags = ?, geom = ? WHERE id = ?]; nested exception is org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of java.util.HashMap. Use setObject() with an explicit Types value to specify the type to use.

@openstreetmap-trac
Copy link
Author

Author: Jocelyn
[Added to the original trac issue at 8.49pm, Wednesday, 29th June 2016]

I've recompiled with version 0.44.1 (commit 0ae17d4999f712685088b44587c83df93a945294), and it works with this version. Let's try some git bisect magic...

@openstreetmap-trac
Copy link
Author

Author: Jocelyn
[Added to the original trac issue at 9.04pm, Wednesday, 29th June 2016]

According to git bisect, the first failing commit is bd4724b1aab8f9461e6b6026f742a97fbbf166a7, which is an update to latest postgis library. I'm still using postgis 1.5.3, so it is logical that osmosis 0.45 is failing.

Should a note be put somewhere on minimal requirements for postgis ?

@openstreetmap-trac
Copy link
Author

Author: samisnunu
[Added to the original trac issue at 2.23pm, Wednesday, 17th August 2016]

Hi,
I got the same error:

SEVERE: Thread for task 1-read-xml-change failed
org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [INSERT INTO nodes(id, version, user_id, tstamp, changeset_id, tags, geom) VALUES (?, ?, ?, ?, ?,
?, ?)]; nested exception is org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of java.util.HashMap. Use setObject() with an explicit Types value to specify t
he type to use.
        at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:99)
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:645)
        at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:866)
        at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:890)
        at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.update(NamedParameterJdbcTemplate.java:287)
        at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.update(NamedParameterJdbcTemplate.java:292)
        at org.openstreetmap.osmosis.pgsnapshot.v0_6.impl.EntityDao.addEntity(EntityDao.java:114)
        at org.openstreetmap.osmosis.pgsnapshot.v0_6.impl.ChangeWriter.write(ChangeWriter.java:128)
        at org.openstreetmap.osmosis.pgsnapshot.v0_6.impl.ActionChangeWriter.process(ActionChangeWriter.java:54)
        at org.openstreetmap.osmosis.core.container.v0_6.NodeContainer.process(NodeContainer.java:58)
        at org.openstreetmap.osmosis.pgsnapshot.v0_6.PostgreSqlChangeWriter.process(PostgreSqlChangeWriter.java:101)
        at org.openstreetmap.osmosis.xml.v0_6.impl.ChangeSourceElementProcessor$ChangeSinkAdapter.process(ChangeSourceElementProcessor.java:144)
        at org.openstreetmap.osmosis.xml.v0_6.impl.NodeElementProcessor.end(NodeElementProcessor.java:139)
        at org.openstreetmap.osmosis.xml.v0_6.impl.OsmChangeHandler.endElement(OsmChangeHandler.java:94)
        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.xml.v0_6.XmlChangeReader.run(XmlChangeReader.java:90)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of java.util.HashMap. Use setObject() with an explicit Types value to specify the type to use.
        at org.postgresql.jdbc2.AbstractJdbc2Statement.setObject(AbstractJdbc2Statement.java:1805)
        at org.postgresql.jdbc3g.AbstractJdbc3gStatement.setObject(AbstractJdbc3gStatement.java:37)
        at org.postgresql.jdbc4.AbstractJdbc4Statement.setObject(AbstractJdbc4Statement.java:46)
        at org.apache.commons.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:169)
        at org.apache.commons.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:169)
        at org.springframework.jdbc.core.StatementCreatorUtils.setValue(StatementCreatorUtils.java:427)
        at org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal(StatementCreatorUtils.java:235)
        at org.springframework.jdbc.core.StatementCreatorUtils.setParameterValue(StatementCreatorUtils.java:150)
        at org.springframework.jdbc.core.PreparedStatementCreatorFactory$PreparedStatementCreatorImpl.setValues(PreparedStatementCreatorFactory.java:292)
        at org.springframework.jdbc.core.PreparedStatementCreatorFactory$PreparedStatementCreatorImpl.createPreparedStatement(PreparedStatementCreatorFactory.java:244)
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:623)
        ... 26 more

That's on:
PostgreSQL 9.5.3-5
Osmosis 0.45
Windows 7 Pro 64-bit

Please help

@openstreetmap-trac
Copy link
Author

Author: brett[at]bretth.com
[Added to the original trac issue at 12.53am, Monday, 29th August 2016]

Replying to [comment:8 samisnunu]:

Hi,
I got the same error:

That's on:
PostgreSQL 9.5.3-5
Osmosis 0.45
Windows 7 Pro 64-bit

What version of Postgis are you using?

@openstreetmap-trac
Copy link
Author

Author: tkk
[Added to the original trac issue at 12.58pm, Thursday, 15th September 2016]

The same for me:

[kasparek@osm data]$ rpm -qa | grep postgis
postgis2_94-2.1.8-1.rhel6.x86_64
postgis2_94-client-2.1.8-1.rhel6.x86_64
[kasparek@osm data]$ rpm -qa | grep postgresql
postgresql94-contrib-9.4.9-1PGDG.rhel6.x86_64
postgresql94-9.4.9-1PGDG.rhel6.x86_64
postgresql94-server-9.4.9-1PGDG.rhel6.x86_64
postgresql94-libs-9.4.9-1PGDG.rhel6.x86_64
postgresql94-devel-9.4.9-1PGDG.rhel6.x86_64

Osmosis 0.45, Centos 6.

Osmosis 0.44.1 is OK.

@openstreetmap-trac
Copy link
Author

Author: tkk
[Added to the original trac issue at 9.49am, Tuesday, 8th November 2016]

Replying to [comment:10 tkk]:

The same for me:

[kasparek@osm data]$ rpm -qa | grep postgis
postgis2_94-2.1.8-1.rhel6.x86_64
postgis2_94-client-2.1.8-1.rhel6.x86_64
[kasparek@osm data]$ rpm -qa | grep postgresql
postgresql94-contrib-9.4.9-1PGDG.rhel6.x86_64
postgresql94-9.4.9-1PGDG.rhel6.x86_64
postgresql94-server-9.4.9-1PGDG.rhel6.x86_64
postgresql94-libs-9.4.9-1PGDG.rhel6.x86_64
postgresql94-devel-9.4.9-1PGDG.rhel6.x86_64

Osmosis 0.45, Centos 6.

Osmosis 0.44.1 is OK.

Still the same with:

[kasparek@osm sources]$ rpm -qa | grep postgis
postgis2_96-client-2.3.0-3.rhel6.x86_64
postgis2_96-2.3.0-3.rhel6.x86_64
[kasparek@osm sources]$ rpm -qa | grep postgresql
postgresql96-server-9.6.1-1PGDG.rhel6.x86_64
postgresql96-libs-9.6.1-1PGDG.rhel6.x86_64
postgresql96-9.6.1-1PGDG.rhel6.x86_64
postgresql96-contrib-9.6.1-1PGDG.rhel6.x86_64
postgresql96-devel-9.6.1-1PGDG.rhel6.x86_64

and still no reaction from developers...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant