Re: hibernatespatial-users Digest, Vol 78, Issue 2

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: hibernatespatial-users Digest, Vol 78, Issue 2

Rolf Wiegand Storgaard
Hi Karel,

Thanks… I fixed the class-loading problem. 

For those interested I have made an article that describes how to setup Hibernate Spatial with Spring etc. running on Tomcat.

http://www.wiegand.dk/wordpress/?p=87 
_____________________________________
Med venlig hilsen / Kind Regards

Rolf Wiegand Storgaard | NorthTech
Nørregade 28D, 4. Th. | 1165 København K  

Den 04/02/2015 kl. 12.00 skrev [hidden email]:

Send hibernatespatial-users mailing list submissions to
[hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users

or, via email, send a message with subject or body 'help' to
[hidden email]

You can reach the person managing the list at
[hidden email]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of hibernatespatial-users digest..."


Today's Topics:

  1. Re: Hibernate Spatial version 4.3 in Spring with a Tomcat
     datasource (Karel Maesen)


----------------------------------------------------------------------

Message: 1
Date: Tue, 3 Feb 2015 22:02:18 +0100
From: Karel Maesen <[hidden email]>
To: Hibernate Spatial Users Discussion
<[hidden email]>
Subject: Re: [hibernatespatial-users] Hibernate Spatial version 4.3 in
Spring with a Tomcat datasource
Message-ID: <[hidden email]>
Content-Type: text/plain; charset=utf-8

Hi Rolf,

The problem lies with how classloaders work in application servers. For the postgresql driver to correctly load the spatial types, it needs to be in the same classlaoder as the postgis.jar. See this discussion: https://gist.github.com/bjornharrtell/3054462

Regards,

Karel



On 02 Feb 2015, at 15:55, Rolf Wiegand Storgaard <[hidden email]> wrote:

Hi,

I am trying to make a setup with Hibernate, Hibernate Spatial, Spring, PostGIS and Tomcat. I have an application up and running and if I configure the datasource in Spring the application works perfect. But... if I configure the datasource in Tomcat as a resource I can?t get it to work. When using the Tomcat datasource I get the Exception:

org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of org.postgis.PGgeometry. Use setObject() with an explicit Types value to specify the type to use.

As you can see below I have specified the type and as mentioned above it works when I specify the datasource direct in spring.

My setup is:

An entity containing:
@Column(name = "GEOM")
@Type(type = "org.hibernate.spatial.GeometryType")
private Geometry geometry;  

Spring configuration:
?
<jee:jndi-lookup id="myDataSource" jndi-name=?MY_DS" default-ref="myDataSourceDefinedInSpring" />
?
<prop key="hibernate.dialect">org.hibernate.spatial.dialect.postgis.PostgisDialect</prop>

Tomcat conf ???: context.xml:
?
<Resource auth="Container"
         maxActive="120"
         maxIdle="10"
         name=?MY_DS"
         username=?username"
         password=?password"
         poolPreparedStatements="true"
         type="javax.sql.DataSource"
         driverClassName="org.postgis.DriverWrapper"
         validatingQuery="select 1"
         url="jdbc:postgresql_postGIS://localhost:5432/mydb"/>
...

Tomcat lib ??? (added JARs):
- hibernate-spatial-4.3.jar
- jts-1.13.jar
- postgis-jdbc-1.5.2.jar
- postgresql-9.3-1102-jdbc41.jar

Hope someone have a good and easy solusion for Hibernate Spatial version 4.3.

_____________________________________
Med venlig hilsen / Kind Regards

Rolf Wiegand Storgaard | NorthTech
N?rregade 28D, 4. Th. | 1165 K?benhavn K  
+45 26 18 86 26 | [hidden email] | http://www.northtech.dk/

_______________________________________________
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


End of hibernatespatial-users Digest, Vol 78, Issue 2
*****************************************************


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