postgresql - Hibernate Spatial & OSGi -


i'm trying use hibernate-spatial in osgi scenario , i'm having hard time getting work.

i'm using jboss fuse/fabric8. stuff running in karaf (2.3.x) container managed transactions. db postgresdb (9.3) postgis running in docker.



problem:


problem retriving geomety datatypes db. can persist entities following error when retrieving spatial data.

java.lang.illegalargumentexception: can't convert object of type org.postgresql.util.pgobject         @ org.hibernate.spatial.dialect.postgis.pggeometryvalueextractor.tojts(pggeometryvalueextractor.java:99) 





context:


bundles loaded in container:

hibernate-commons-annotations (4.0.4.final) hibernate-core (4.2.10.final) hibernate-entitymanager (4.2.10.final) hibernate-osgi (4.2.10.final) jts topology suite (1.12) hibernate spatial (4.0) postgis jdbc driver (1.5.8) postgresql jdbc4 driver (9.1.902.jdbc4) 

the entity:

...       @column(nullable = false, unique = true)       @type(type = "org.hibernate.spatial.geometrytype")       private point location; ... 

the datasource:

  <bean     id="data_source_postgres" class="org.postgresql.ds.pgpoolingdatasource">     <property name="servername" value="servername" />     <property name="portnumber" value="portnumber" />     <property name="databasename" value="databasename" />     <property name="user" value="user" />     <property name="password" value="password" />   </bean>    <service ref="data_source_postgres" interface="javax.sql.datasource">     <service-properties>       <entry key="osgi.jndi.service.name" value="jdbc/postgresds" />       <entry key="service.exported.interfaces" value="*" />     </service-properties>   </service> 

the persistence.xml:

<persistence-unit name="pu" transaction-type="jta">     <provider>org.hibernate.ejb.hibernatepersistence</provider>     <jta-data-source>osgi:service/javax.sql.datasource/(osgi.jndi.service.name=jdbc/postgresds)</jta-data-source>     <class>entities.fooentity</class>     <exclude-unlisted-classes>true</exclude-unlisted-classes>     <properties>                   <property name="hibernate.dialect" value="org.hibernate.spatial.dialect.postgis.postgisdialect"/>       <property name="hibernate.archive.autodetection" value="class, hbm" />       <property name="hibernate.hbm2ddl.auto" value="create" />       <property name="hibernate.show_sql" value="true" />       <property name="hibernate.format_sql" value="true" />     </properties>   </persistence-unit> 





facts, conclusions , questions:

  1. when run code outside karaf against same db, same dependencies hand managed transaction, works fine. leaves me conclude problem not incompatibility between of dependencies. if case, wouldn't work when running outside karaf.

  2. i've checked org.hibernate.spatial.dialect.postgis.pggeometryvalueextractor.tojts implementation , conclude not supposed retrieved object type pgobject @ all! in case should org.postgis.geometry.point

  3. reading similar post other people i've thought appropriate data types wouldn't registered properly. if case, persisting geometry success , failing retrieve it? how can check datatypes in fact registered?

  4. whats root of problem? container managed transaction (aires)? bundles not exporting supposed to? dependencies versions? using wrong dialect/driver/datasource?

in osgi when encounter things make absolutely no sense, check class loading issues.

since method called totally unexpected type (you expected object postgis , received 1 postgress) think @ point previous conversion has failed. check , see if there single package exported (or embedded) multiple bundles common source of such issues.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -