ClassCastException when loading a point from PostGIS

7 messages Options
Embed this post
Permalink
Sebastien ARBOGAST

ClassCastException when loading a point from PostGIS

Reply Threaded More More options
Print post
Permalink
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)

I would have liked to debug hibernate-spatial code to see what's wrong
inside, but I couldn't find the specific source corresponding to the
latest release.

And I tried to check out the latest sources but I couldn't build it
because of missing dependencies.

Thx in advance for your help?

--
Sébastien Arbogast

http://www.sebastien-arbogast.com
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Karel Maesen

Re: ClassCastException when loading a point from PostGIS

Reply Threaded More More options
Print post
Permalink
Hi Sebastien,

On 07 Jan 2008, at 18:44, Sebastien ARBOGAST wrote:

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

What versions of the postgresql/postgis drivers are you using?

> I would have liked to debug hibernate-spatial code to see what's wrong
> inside, but I couldn't find the specific source corresponding to the
> latest release.
>
> And I tried to check out the latest sources but I couldn't build it
> because of missing dependencies.

The easiest way to build Hibernate Spatial is to check out all  
projects from the subversion repository.

 > svn checkout https://intra.geovise.com/svn/hibernate-spatial/trunk 
hibernate-spatial

then move to the hibernate-spatial/hibernate-spatial-maven directory  
and run

 > mvn package  (or mvn install)

This will resolve all dependencies, download the necessary jars,  
compile everything and build the jars.

Unfortunately, maven won't be able to get some jars automatically  
using the standard JTS configuration. Try adding the following to the  
maven settings.xml in the <repositories> settings (see the maven  
documentation about this).

      <repository>
           <id>geotools</id>
           <name>GeoTools repo</name>
           <url>http://www.geotools.fr/repository</url>
           <releases>
             <enabled>true</enabled>
             <updatePolicy>daily</updatePolicy>
           </releases>
           <snapshots>
             <enabled>true</enabled>
             <updatePolicy>daily</updatePolicy>
           </snapshots>
         </repository>

This will allow maven to get most postgis and jts libraries from a  
public maven repository.

The Oracle and JTA drivers must be downloaded and installed manually  
in the maven repository. If you run 'mvn package' without having  
installed these libraries, it will inform you on how to install them.  
After that everything should install fine.

Btw, I think this particular problem has been resolved in the trunk  
version.

Regards,

Karel Maesen
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Sebastien ARBOGAST

Re: ClassCastException when loading a point from PostGIS

Reply Threaded More More options
Print post
Permalink
Hi Karel,

> > 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)
> >
>
> What versions of the postgresql/postgis drivers are you using?

I'm using postgis-1.3.2 and postgresql-8.2-504.jdbc3


> > I would have liked to debug hibernate-spatial code to see what's wrong
> > inside, but I couldn't find the specific source corresponding to the
> > latest release.
> >
> > And I tried to check out the latest sources but I couldn't build it
> > because of missing dependencies.
>
> The easiest way to build Hibernate Spatial is to check out all
> projects from the subversion repository.
>
>  > svn checkout https://intra.geovise.com/svn/hibernate-spatial/trunk
> hibernate-spatial
>
> then move to the hibernate-spatial/hibernate-spatial-maven directory
> and run
>
>  > mvn package  (or mvn install)
>
> This will resolve all dependencies, download the necessary jars,
> compile everything and build the jars.
>
> Unfortunately, maven won't be able to get some jars automatically
> using the standard JTS configuration. Try adding the following to the
> maven settings.xml in the <repositories> settings (see the maven
> documentation about this).
>
>       <repository>
>            <id>geotools</id>
>            <name>GeoTools repo</name>
>            <url>http://www.geotools.fr/repository</url>
>            <releases>
>              <enabled>true</enabled>
>              <updatePolicy>daily</updatePolicy>
>            </releases>
>            <snapshots>
>              <enabled>true</enabled>
>              <updatePolicy>daily</updatePolicy>
>            </snapshots>
>          </repository>
>
> This will allow maven to get most postgis and jts libraries from a
> public maven repository.
>
> The Oracle and JTA drivers must be downloaded and installed manually
> in the maven repository. If you run 'mvn package' without having
> installed these libraries, it will inform you on how to install them.
> After that everything should install fine.

FYI, GeoTools repository has moved to maven.geotools.fr/repository.
But even with this configuration, there are still some dependencies
that cannot be resolved:

[INFO] Failed to resolve artifact.

GroupId: com.cadrie
ArtifactId: maven-header-plugin
Version: 1.0

Reason: Unable to download the artifact from any repository

  com.cadrie:maven-header-plugin:pom:1.0

from the specified remote repositories:
  central (http://repo1.maven.org/maven2),
  andromda (http://team.andromda.org/maven2),
  geotools (http://maven.geotools.fr/repository)


> Btw, I think this particular problem has been resolved in the trunk
> version.
>
> Regards,
>
> Karel Maesen
> _______________________________________________
> hibernatespatial-users mailing list
> [hidden email]
> http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
>


--
Sébastien Arbogast

http://www.sebastien-arbogast.com
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Karel Maesen

Re: ClassCastException when loading a point from PostGIS

Reply Threaded More More options
Print post
Permalink
Hi Sebastien,

On 07 Jan 2008, at 21:31, Sebastien ARBOGAST wrote:

>
> FYI, GeoTools repository has moved to maven.geotools.fr/repository.
> But even with this configuration, there are still some dependencies
> that cannot be resolved:

Thanks for pointing that out. I missed that.


>
> [INFO] Failed to resolve artifact.
>
> GroupId: com.cadrie
> ArtifactId: maven-header-plugin
> Version: 1.0
>
> Reason: Unable to download the artifact from any repository
>
>   com.cadrie:maven-header-plugin:pom:1.0
>


Just comment out that dependency. It's not crucial to building the  
Hibernate Spatial libraries. (I'll remove that dependency soon).

Regards,

Karel
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Sebastien ARBOGAST

Re: ClassCastException when loading a point from PostGIS

Reply Threaded More More options
Print post
Permalink
Thanks Karel! I managed to build Hibernate Spatial so now I'm using
the latest version but I still have a similar exception:

Caused by: java.lang.IllegalArgumentException: Can't convert object of
type org.postgresql.util.PGobject at
org.hibernatespatial.postgis.PGGeometryUserType.convert2JTS(PGGeometryUserType.java:120)
at org.hibernatespatial.AbstractDBGeometryType.nullSafeGet(AbstractDBGeometryType.java:123)
at org.hibernatespatial.GeometryUserType.nullSafeGet(GeometryUserType.java:169)
...

It seems that the wrong type of object is still loaded from the database.

2008/1/8, Karel Maesen <[hidden email]>:

> Hi Sebastien,
>
> On 07 Jan 2008, at 21:31, Sebastien ARBOGAST wrote:
>
> >
> > FYI, GeoTools repository has moved to maven.geotools.fr/repository.
> > But even with this configuration, there are still some dependencies
> > that cannot be resolved:
>
> Thanks for pointing that out. I missed that.
>
>
> >
> > [INFO] Failed to resolve artifact.
> >
> > GroupId: com.cadrie
> > ArtifactId: maven-header-plugin
> > Version: 1.0
> >
> > Reason: Unable to download the artifact from any repository
> >
> >   com.cadrie:maven-header-plugin:pom:1.0
> >
>
>
> Just comment out that dependency. It's not crucial to building the
> Hibernate Spatial libraries. (I'll remove that dependency soon).
>
> Regards,
>
> Karel
> _______________________________________________
> hibernatespatial-users mailing list
> [hidden email]
> http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
>


--
Sébastien Arbogast

http://www.sebastien-arbogast.com
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Karel Maesen

Re: ClassCastException when loading a point from PostGIS

Reply Threaded More More options
Print post
Permalink
Hi Sebastien,

If everything is properly configured the "convert2JTS" should receive  
a PGGeometry object, not a PGobject. Could it be that postgis.jar is  
not properly installed?

If you are working on a web-application 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).

Regards,

Karel



On 08 Jan 2008, at 11:49, Sebastien ARBOGAST wrote:

> Thanks Karel! I managed to build Hibernate Spatial so now I'm using
> the latest version but I still have a similar exception:
>
> Caused by: java.lang.IllegalArgumentException: Can't convert object of
> type org.postgresql.util.PGobject at
> org.hibernatespatial.postgis.PGGeometryUserType.convert2JTS
> (PGGeometryUserType.java:120)
> at org.hibernatespatial.AbstractDBGeometryType.nullSafeGet
> (AbstractDBGeometryType.java:123)
> at org.hibernatespatial.GeometryUserType.nullSafeGet
> (GeometryUserType.java:169)
> ...
>
> It seems that the wrong type of object is still loaded from the  
> database.
>
> 2008/1/8, Karel Maesen <[hidden email]>:
>> Hi Sebastien,
>>
>> On 07 Jan 2008, at 21:31, Sebastien ARBOGAST wrote:
>>
>>>
>>> FYI, GeoTools repository has moved to maven.geotools.fr/repository.
>>> But even with this configuration, there are still some dependencies
>>> that cannot be resolved:
>>
>> Thanks for pointing that out. I missed that.
>>
>>
>>>
>>> [INFO] Failed to resolve artifact.
>>>
>>> GroupId: com.cadrie
>>> ArtifactId: maven-header-plugin
>>> Version: 1.0
>>>
>>> Reason: Unable to download the artifact from any repository
>>>
>>>   com.cadrie:maven-header-plugin:pom:1.0
>>>
>>
>>
>> Just comment out that dependency. It's not crucial to building the
>> Hibernate Spatial libraries. (I'll remove that dependency soon).
>>
>> Regards,
>>
>> Karel
>> _______________________________________________
>> hibernatespatial-users mailing list
>> [hidden email]
>> http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/ 
>> hibernatespatial-users
>>
>
>
> --
> Sébastien Arbogast
>
> http://www.sebastien-arbogast.com
> _______________________________________________
> hibernatespatial-users mailing list
> [hidden email]
> http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/ 
> hibernatespatial-users

_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Sebastien ARBOGAST

Re: ClassCastException when loading a point from PostGIS

Reply Threaded More More options
Print post
Permalink
That's it! It works! Woohooooo!
Thanks a lot.

2008/1/8, Karel Maesen <[hidden email]>:

> Hi Sebastien,
>
> If everything is properly configured the "convert2JTS" should receive
> a PGGeometry object, not a PGobject. Could it be that postgis.jar is
> not properly installed?
>
> If you are working on a web-application 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).
>
> Regards,
>
> Karel
>
>
>
> On 08 Jan 2008, at 11:49, Sebastien ARBOGAST wrote:
>
> > Thanks Karel! I managed to build Hibernate Spatial so now I'm using
> > the latest version but I still have a similar exception:
> >
> > Caused by: java.lang.IllegalArgumentException: Can't convert object of
> > type org.postgresql.util.PGobject at
> > org.hibernatespatial.postgis.PGGeometryUserType.convert2JTS
> > (PGGeometryUserType.java:120)
> > at org.hibernatespatial.AbstractDBGeometryType.nullSafeGet
> > (AbstractDBGeometryType.java:123)
> > at org.hibernatespatial.GeometryUserType.nullSafeGet
> > (GeometryUserType.java:169)
> > ...
> >
> > It seems that the wrong type of object is still loaded from the
> > database.
> >
> > 2008/1/8, Karel Maesen <[hidden email]>:
> >> Hi Sebastien,
> >>
> >> On 07 Jan 2008, at 21:31, Sebastien ARBOGAST wrote:
> >>
> >>>
> >>> FYI, GeoTools repository has moved to maven.geotools.fr/repository.
> >>> But even with this configuration, there are still some dependencies
> >>> that cannot be resolved:
> >>
> >> Thanks for pointing that out. I missed that.
> >>
> >>
> >>>
> >>> [INFO] Failed to resolve artifact.
> >>>
> >>> GroupId: com.cadrie
> >>> ArtifactId: maven-header-plugin
> >>> Version: 1.0
> >>>
> >>> Reason: Unable to download the artifact from any repository
> >>>
> >>>   com.cadrie:maven-header-plugin:pom:1.0
> >>>
> >>
> >>
> >> Just comment out that dependency. It's not crucial to building the
> >> Hibernate Spatial libraries. (I'll remove that dependency soon).
> >>
> >> Regards,
> >>
> >> Karel
> >> _______________________________________________
> >> hibernatespatial-users mailing list
> >> [hidden email]
> >> http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/
> >> hibernatespatial-users
> >>
> >
> >
> > --
> > Sébastien Arbogast
> >
> > http://www.sebastien-arbogast.com
> > _______________________________________________
> > hibernatespatial-users mailing list
> > [hidden email]
> > http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/
> > hibernatespatial-users
>
> _______________________________________________
> hibernatespatial-users mailing list
> [hidden email]
> http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
>


--
Sébastien Arbogast

http://www.sebastien-arbogast.com
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users