Opened 3 years ago

Last modified 2 years ago

#5407 new defect

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

Reported by: Jocelyn Owned by: bretth
Priority: minor Milestone:
Component: osmosis Version:
Keywords: Cc: Jocelyn

Description

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 ?

Change History (11)

comment:1 Changed 3 years ago by Jocelyn

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.

Last edited 3 years ago by Jocelyn (previous) (diff)

comment:2 Changed 3 years ago by bretth

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

comment:3 Changed 3 years ago by bretth

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

comment:4 Changed 3 years ago by Jocelyn

Cc: Jocelyn added

comment:5 Changed 3 years ago by Jocelyn

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.

comment:6 Changed 3 years ago by Jocelyn

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

comment:7 Changed 3 years ago by Jocelyn

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 ?

comment:8 Changed 3 years ago by samisnunu

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

comment:9 in reply to:  8 Changed 3 years ago by bretth

Replying to samisnunu:

Hi, I got the same error:

<snip>

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

What version of Postgis are you using?

comment:10 Changed 3 years ago by 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.

Last edited 3 years ago by tkk (previous) (diff)

comment:11 in reply to:  10 Changed 2 years ago by tkk

Replying to 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...

Note: See TracTickets for help on using tickets.