2

When I try to load points from a PostGIS database, I get the following exception:

Caused by: java.lang.ClassCastException: org.postgresql.util.PGobject
        at org.hibernatespatial.postgis.PGGeometryUserType.convert2JTS(PGGeometryUserType.java:75)
        at org.hibernatespatial.AbstractDBGeometryType.nullSafeGet(AbstractDBGeometryType.java:123)
        at org.hibernatespatial.GeometryUserType.nullSafeGet(GeometryUserType.java:169) 
Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
lakshmi
  • 4,539
  • 17
  • 47
  • 55

1 Answers1

3

It looks like the problem described in PGobject cannot be cast to PGgeometry so I'll quote the relevant answer:

I guess you run into the same problem as Sebastien Arbogast a while back. If you use Hibernate Spatial in a web container with the JDBC provided by the container through JNDI, then the postgis.jar should also be installed together with the JDBC driver and should not be contained in the WEB-INF/lib directory.

Of course, this is a shot in the dark since you didn't mention anything about your environment and didn't provide the full stack trace.

Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • Good advice! But if you already have geoserver in same server where you want to place your web app, you will face a problem to load geoserver after adding additional postgis.jar. I haven't find solution for this case yet. – Mario Mar 17 '15 at 09:51
  • One of solutions is to remove postgresql jar from geoserver lib path so geoserver will be using e.g. tomcat's libs. – Mario Mar 17 '15 at 10:36