can't load Entities with field of type org.hibernate.spatial.GeometryType

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

can't load Entities with field of type org.hibernate.spatial.GeometryType

DoBe

Hi,

(I also posted this on stackoverflow at: http://stackoverflow.com/questions/23270071/cant-convert-object-of-type-org-postgresql-util-pgobject)

I have a problem with using Hibernate Spatial and PostGIS. I have an entity with a field like this:

public class LocationBean {
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private long id;

  @Type(type = "org.hibernate.spatial.GeometryType")
  private Point location;
}

The problem I have is that I can't load any of these entities from the database, unless location is null for that entity. If it is not null, I get the following error:

Exception: Can't convert object of type org.postgresql.util.PGobject
javax.el.ELException: /protected/topPanel/searchBar.xhtml @27,57 completeMethod="#{toppanelbb.completeSearchBar}": java.lang.IllegalArgumentException: Can't convert object of type org.postgresql.util.PGobject
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:111)
at org.primefaces.component.autocomplete.AutoComplete.broadcast(AutoComplete.java:337)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:931)
at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:344)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:70)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.glassfish.tyrus.servlet.TyrusServletFilter.doFilter(TyrusServletFilter.java:253)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:205)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.IllegalArgumentException: Can't convert object of type org.postgresql.util.PGobject
at org.hibernate.spatial.dialect.postgis.PGGeometryValueExtractor.toJTS(PGGeometryValueExtractor.java:113)
at org.hibernate.spatial.dialect.AbstractJTSGeometryValueExtractor.doExtract(AbstractJTSGeometryValueExtractor.java:50)
at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:267)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:263)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:253)
at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:338)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2969)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1695)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1627)
at org.hibernate.loader.Loader.getRow(Loader.java:1514)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:725)
at org.hibernate.loader.Loader.processResultSet(Loader.java:952)
at org.hibernate.loader.Loader.doQuery(Loader.java:920)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:354)
at org.hibernate.loader.Loader.doList(Loader.java:2553)
at org.hibernate.loader.Loader.doList(Loader.java:2539)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2369)
at org.hibernate.loader.Loader.list(Loader.java:2364)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:496)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:387)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:231)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1264)
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:103)
at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:573)
at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:449)
at com.sun.enterprise.container.common.impl.QueryWrapper.getResultList(QueryWrapper.java:84)
at com.dobe.app.backingbeans.TopPanelBackingBean.completeSearchBar(TopPanelBackingBean.java:289)
at com.dobe.app.backingbeans.TopPanelBackingBean$Proxy$_$$_WeldClientProxy.completeSearchBar(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.el.parser.AstValue.invoke(AstValue.java:275)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
... 45 more

The weird thing is that I can persist them just fine, but not load them. For example, if I do something like:

LocationBean loc = new LocationBean();
loc.setLocation(new GeometryFactory.createPoint(new Coordinate(lon, lat));
// persist to db...

The point is correctly stored correctly in the Postgresql database and querying it works. Only when I load it, it doesn't work.

I can also load other fields from the class, besides the location field. So for instance:

Query query = em.createQuery("SELECT l.id from LocationBean l  WHERE within(v.location, :filter) = true", Long.class);

would work, but:

Query query = em.createQuery("SELECT l from LocationBean l  WHERE within(v.location, :filter) = true", LocationBean.class);

would not.

These are the dependencies in my pom.xml:

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.3.5.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.3.5.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-spatial</artifactId>
        <version>4.3-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.2-1002.jdbc4</version>
    </dependency>
    <dependency>
        <groupId>org.postgis</groupId>
        <artifactId>postgis-jdbc</artifactId>
        <version>1.5.2</version>
    </dependency>

Any ideas what I could try? I have a workaround solution at the moment, where I only use the persisted GeometryType for querying, but don't ever load it into a java object, but I am not happy with that solution. Thanks!

Cheers,
Dominik


_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Reply | Threaded
Open this post in threaded view
|

Re: can't load Entities with field of type org.hibernate.spatial.GeometryType

Karel Maesen
Administrator
Hi Dominik,

It seems to me dat the Postgis JDBC extension jar is not available in the classloader. Kan you check that it is on the classpath, and loaded by the proper classloader?

Classloader issues are common when using a J2EE container where the database connection is in some way or another managed by the container. The JDBC and the Postgis.jar need to be loaded by the same classloader. The fact that you get a PGobject where a PGgeometry is expected is a common symptom that this is not happening in your application.

Regards,

Karel

On 24 Apr 2014, at 17:47, Dominik Beste <[hidden email]> wrote:

> Hi,
>
> (I also posted this on stackoverflow at: http://stackoverflow.com/questions/23270071/cant-convert-object-of-type-org-postgresql-util-pgobject)
>
> I have a problem with using Hibernate Spatial and PostGIS. I have an entity with a field like this:
> public class LocationBean {
>
>  
> @
> Id
>  
> @GeneratedValue(strategy = GenerationType.AUTO)
>
>   private long id
> ;
>
>
>  
> @Type(type = "org.hibernate.spatial.GeometryType")
>
>   private Point location
> ;
> }
> The problem I have is that I can't load any of these entities from the database, unless location is null for that entity. If it is not null, I get the following error:
>
> Exception: Can
> 't convert object of type org.postgresql.util.PGobject
> javax.el.ELException: /protected/topPanel/searchBar.xhtml @27,57 completeMethod="#{toppanelbb.completeSearchBar}": java.lang.IllegalArgumentException: Can'
> t convert object of type org.postgresql.util.
> PGobject
> at com
> .sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:111)
>
> at org
> .primefaces.component.autocomplete.AutoComplete.broadcast(AutoComplete.java:337)
>
> at javax
> .faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
>
> at javax
> .faces.component.UIViewRoot.processDecodes(UIViewRoot.java:931)
>
> at com
> .sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
>
> at com
> .sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
>
> at com
> .sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
>
> at javax
> .faces.webapp.FacesServlet.service(FacesServlet.java:646)
>
> at org
> .apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
>
> at org
> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:344)
>
> at org
> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
>
> at org
> .primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:70)
>
> at org
> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
>
> at org
> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
>
> at org
> .glassfish.tyrus.servlet.TyrusServletFilter.doFilter(TyrusServletFilter.java:253)
>
> at org
> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
>
> at org
> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
>
> at org
> .ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:205)
>
> at org
> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
>
> at org
> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
>
> at org
> .apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316)
>
> at org
> .apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
>
> at org
> .apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
>
> at org
> .apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
>
> at com
> .sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
>
> at org
> .apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
>
> at org
> .apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
>
> at org
> .apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
>
> at com
> .sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
>
> at org
> .glassfish.grizzly.http.server<arrow-10x10.png>.HttpHandler.runService(HttpHandler.java:191)
>
> at org
> .glassfish.grizzly.http.server<arrow-10x10.png>.HttpHandler.doHandle(HttpHandler.java:168)
>
> at org
> .glassfish.grizzly.http.server<arrow-10x10.png>.HttpServerFilter.handleRead(HttpServerFilter.java:189)
>
> at org
> .glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
>
> at org
> .glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
>
> at org
> .glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
>
> at org
> .glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
>
> at org
> .glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
>
> at org
> .glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
>
> at org
> .glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
>
> at org
> .glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
>
> at org
> .glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
>
> at org
> .glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
>
> at org
> .glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
>
> at org
> .glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
>
> at org
> .glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
>
> at java
> .lang.Thread.run(Thread.java:744)
>
> Caused
> by: java.lang.IllegalArgumentException: Can't convert object of type org.postgresql.util.
> PGobject
> at org
> .hibernate.spatial.dialect.postgis.PGGeometryValueExtractor.toJTS(PGGeometryValueExtractor.java:113)
>
> at org
> .hibernate.spatial.dialect.AbstractJTSGeometryValueExtractor.doExtract(AbstractJTSGeometryValueExtractor.java:50)
>
> at org
> .hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64)
>
> at org
> .hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:267)
>
> at org
> .hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:263)
>
> at org
> .hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:253)
>
> at org
> .hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:338)
>
> at org
> .hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2969)
>
> at org
> .hibernate.loader.Loader.loadFromResultSet(Loader.java:1695)
>
> at org
> .hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1627)
>
> at org
> .hibernate.loader.Loader.getRow(Loader.java:1514)
>
> at org
> .hibernate.loader.Loader.getRowFromResultSet(Loader.java:725)
>
> at org
> .hibernate.loader.Loader.processResultSet(Loader.java:952)
>
> at org
> .hibernate.loader.Loader.doQuery(Loader.java:920)
>
> at org
> .hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:354)
>
> at org
> .hibernate.loader.Loader.doList(Loader.java:2553)
>
> at org
> .hibernate.loader.Loader.doList(Loader.java:2539)
>
> at org
> .hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2369)
>
> at org
> .hibernate.loader.Loader.list(Loader.java:2364)
>
> at org
> .hibernate.loader.hql.QueryLoader.list(QueryLoader.java:496)
>
> at org
> .hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:387)
>
> at org
> .hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:231)
>
> at org
> .hibernate.internal.SessionImpl.list(SessionImpl.java:1264)
>
> at org
> .hibernate.internal.QueryImpl.list(QueryImpl.java:103)
>
> at org
> .hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:573)
>
> at org
> .hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:449)
>
> at com
> .sun.enterprise.container.common.impl.QueryWrapper.getResultList(QueryWrapper.java:84)
>
> at com
> .dobe.app.backingbeans.TopPanelBackingBean.completeSearchBar(TopPanelBackingBean.java:289)
>
> at com
> .dobe.app.backingbeans.TopPanelBackingBean$Proxy$_$$_WeldClientProxy.completeSearchBar(Unknown<arrow-10x10.png> Source)
>
> at sun
> .reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
> at sun
> .reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>
> at sun
> .reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
> at java
> .lang.reflect.Method.invoke(Method.java:606)
>
> at com
> .sun.el.parser.AstValue.invoke(AstValue.java:275)
>
> at com
> .sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
>
> at org
> .jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
>
> at org
> .jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
>
> at com
> .sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
> ... 45 more
> The weird thing is that I can persist them just fine, but not load them. For example, if I do something like:
>
> LocationBean loc = new LocationBean();
>
> loc
> .setLocation(new GeometryFactory.createPoint(new Coordinate(lon, lat));
> // persist to db...
> The point is correctly stored correctly in the Postgresql database and querying it works. Only when I load it, it doesn't work.
>
> I can also load other fields from the class, besides the location field. So for instance:
>
> Query query = em.createQuery("SELECT l.id from LocationBean l  WHERE within(v.location, :filter) = true", Long.class);
> would work, but:
>
> Query query = em.createQuery("SELECT l from LocationBean l  WHERE within(v.location, :filter) = true", LocationBean.class);
> would not.
>
> These are the dependencies in my pom.xml:
>
>     <dependency>
>
>        
> <groupId>org.hibernate</groupId>
>
>        
> <artifactId>hibernate-core</artifactId>
>
>        
> <version>4.3.5.Final</version>
>
>    
> </dependency>
>
>    
> <dependency>
>
>        
> <groupId>org.hibernate</groupId>
>
>        
> <artifactId>hibernate-entitymanager</artifactId>
>
>        
> <version>4.3.5.Final</version>
>
>    
> </dependency>
>
>    
> <dependency>
>
>        
> <groupId>org.hibernate</groupId>
>
>        
> <artifactId>hibernate-spatial</artifactId>
>
>        
> <version>4.3-SNAPSHOT</version>
>
>    
> </dependency>
>
>    
> <dependency>
>
>        
> <groupId>postgresql</groupId>
>
>        
> <artifactId>postgresql</artifactId>
>
>        
> <version>9.2-1002.jdbc4</version>
>
>    
> </dependency>
>
>    
> <dependency>
>
>        
> <groupId>org.postgis</groupId>
>
>        
> <artifactId>postgis-jdbc</artifactId>
>
>        
> <version>1.5.2</version>
>
>    
> </dependency>
> Any ideas what I could try? I have a workaround solution at the moment, where I only use the persisted GeometryType for querying, but don't ever load it into a java object, but I am not happy with that solution. Thanks!
> Cheers,
> Dominik
> _______________________________________________
> 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
Reply | Threaded
Open this post in threaded view
|

Re: can't load Entities with field of type org.hibernate.spatial.GeometryType

DoBe
Hi Karel,

Thanks for your quick reply. I am using Glassfish 4.0 as my application
server. I don't know how I can check if the classloader is loading it
correctly.

The relevant bits from my server log when I deploy my app are:

INFO:   HHH000204: Processing PersistenceUnitInfo [
     name: PU_Hibernate_PostgreSQL
     ...]
INFO:   HHH000412: Hibernate Core {4.3.5.Final}
INFO:   HHH000206: hibernate.properties not found
INFO:   HHH000021: Bytecode provider name : javassist
INFO:   HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
INFO:   HHH000400: Using dialect:
org.hibernate.spatial.dialect.postgis.PostgisDialect
INFO:   HHH000424: Disabling contextual LOB creation as createClob()
method threw error : java.lang.reflect.InvocationTargetException

hibernate.properties is not found, because I have all my configurations
in the persistence.xml file:

<persistence-unit name="PU_Hibernate_PostgreSQL" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>jdbc/PostgreSQL</jta-data-source>
     <properties>
       <property name="hibernate.dialect"
value="org.hibernate.spatial.dialect.postgis.PostgisDialect"/>
       <property name="hibernate.connection.url"
value="jdbc:postgresql://...."/>
       <property name="hibernate.connection.driver_class"
value="org.postgresql.Driver"/>
       <property name="hibernate.connection.username" value="postgres"/>
       <property name="hibernate.connection.password" value="***"/>
       <property name="hibernate.default_schema" value="public"/>
       <property name="hibernate.transaction.jta.platform"
value="org.hibernate.service.jta.platform.internal.SunOneJtaPlatform"/>
       <property name="hibernate.connection.autocommit" value="false"/>
       <property name="hibernate.enable_lazy_load_no_trans" value="true"/>
     </properties>
   </persistence-unit>

I'll try to find out more about that classloader thing and let you know
if I make any progress. Thanks for your help so far.

Cheers,

Dominik


On 24/04/2014 17:03, Karel Maesen wrote:

> Hi Dominik,
>
> It seems to me dat the Postgis JDBC extension jar is not available in the classloader. Kan you check that it is on the classpath, and loaded by the proper classloader?
>
> Classloader issues are common when using a J2EE container where the database connection is in some way or another managed by the container. The JDBC and the Postgis.jar need to be loaded by the same classloader. The fact that you get a PGobject where a PGgeometry is expected is a common symptom that this is not happening in your application.
>
> Regards,
>
> Karel
>
> On 24 Apr 2014, at 17:47, Dominik Beste <[hidden email]> wrote:
>
>> Hi,
>>
>> (I also posted this on stackoverflow at: http://stackoverflow.com/questions/23270071/cant-convert-object-of-type-org-postgresql-util-pgobject)
>>
>> I have a problem with using Hibernate Spatial and PostGIS. I have an entity with a field like this:
>> public class LocationBean {
>>
>>    
>> @
>> Id
>>    
>> @GeneratedValue(strategy = GenerationType.AUTO)
>>
>>    private long id
>> ;
>>
>>
>>    
>> @Type(type = "org.hibernate.spatial.GeometryType")
>>
>>    private Point location
>> ;
>> }
>> The problem I have is that I can't load any of these entities from the database, unless location is null for that entity. If it is not null, I get the following error:
>>
>> Exception: Can
>> 't convert object of type org.postgresql.util.PGobject
>> javax.el.ELException: /protected/topPanel/searchBar.xhtml @27,57 completeMethod="#{toppanelbb.completeSearchBar}": java.lang.IllegalArgumentException: Can'
>> t convert object of type org.postgresql.util.
>> PGobject
>> at com
>> .sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:111)
>>
>> at org
>> .primefaces.component.autocomplete.AutoComplete.broadcast(AutoComplete.java:337)
>>
>> at javax
>> .faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
>>
>> at javax
>> .faces.component.UIViewRoot.processDecodes(UIViewRoot.java:931)
>>
>> at com
>> .sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
>>
>> at com
>> .sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
>>
>> at com
>> .sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
>>
>> at javax
>> .faces.webapp.FacesServlet.service(FacesServlet.java:646)
>>
>> at org
>> .apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
>>
>> at org
>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:344)
>>
>> at org
>> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
>>
>> at org
>> .primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:70)
>>
>> at org
>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
>>
>> at org
>> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
>>
>> at org
>> .glassfish.tyrus.servlet.TyrusServletFilter.doFilter(TyrusServletFilter.java:253)
>>
>> at org
>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
>>
>> at org
>> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
>>
>> at org
>> .ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:205)
>>
>> at org
>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
>>
>> at org
>> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
>>
>> at org
>> .apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316)
>>
>> at org
>> .apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
>>
>> at org
>> .apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
>>
>> at org
>> .apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
>>
>> at com
>> .sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
>>
>> at org
>> .apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
>>
>> at org
>> .apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
>>
>> at org
>> .apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
>>
>> at com
>> .sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
>>
>> at org
>> .glassfish.grizzly.http.server<arrow-10x10.png>.HttpHandler.runService(HttpHandler.java:191)
>>
>> at org
>> .glassfish.grizzly.http.server<arrow-10x10.png>.HttpHandler.doHandle(HttpHandler.java:168)
>>
>> at org
>> .glassfish.grizzly.http.server<arrow-10x10.png>.HttpServerFilter.handleRead(HttpServerFilter.java:189)
>>
>> at org
>> .glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
>>
>> at org
>> .glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
>>
>> at org
>> .glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
>>
>> at org
>> .glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
>>
>> at org
>> .glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
>>
>> at org
>> .glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
>>
>> at org
>> .glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
>>
>> at org
>> .glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
>>
>> at org
>> .glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
>>
>> at org
>> .glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
>>
>> at org
>> .glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
>>
>> at org
>> .glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
>>
>> at org
>> .glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
>>
>> at java
>> .lang.Thread.run(Thread.java:744)
>>
>> Caused
>> by: java.lang.IllegalArgumentException: Can't convert object of type org.postgresql.util.
>> PGobject
>> at org
>> .hibernate.spatial.dialect.postgis.PGGeometryValueExtractor.toJTS(PGGeometryValueExtractor.java:113)
>>
>> at org
>> .hibernate.spatial.dialect.AbstractJTSGeometryValueExtractor.doExtract(AbstractJTSGeometryValueExtractor.java:50)
>>
>> at org
>> .hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64)
>>
>> at org
>> .hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:267)
>>
>> at org
>> .hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:263)
>>
>> at org
>> .hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:253)
>>
>> at org
>> .hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:338)
>>
>> at org
>> .hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2969)
>>
>> at org
>> .hibernate.loader.Loader.loadFromResultSet(Loader.java:1695)
>>
>> at org
>> .hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1627)
>>
>> at org
>> .hibernate.loader.Loader.getRow(Loader.java:1514)
>>
>> at org
>> .hibernate.loader.Loader.getRowFromResultSet(Loader.java:725)
>>
>> at org
>> .hibernate.loader.Loader.processResultSet(Loader.java:952)
>>
>> at org
>> .hibernate.loader.Loader.doQuery(Loader.java:920)
>>
>> at org
>> .hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:354)
>>
>> at org
>> .hibernate.loader.Loader.doList(Loader.java:2553)
>>
>> at org
>> .hibernate.loader.Loader.doList(Loader.java:2539)
>>
>> at org
>> .hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2369)
>>
>> at org
>> .hibernate.loader.Loader.list(Loader.java:2364)
>>
>> at org
>> .hibernate.loader.hql.QueryLoader.list(QueryLoader.java:496)
>>
>> at org
>> .hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:387)
>>
>> at org
>> .hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:231)
>>
>> at org
>> .hibernate.internal.SessionImpl.list(SessionImpl.java:1264)
>>
>> at org
>> .hibernate.internal.QueryImpl.list(QueryImpl.java:103)
>>
>> at org
>> .hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:573)
>>
>> at org
>> .hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:449)
>>
>> at com
>> .sun.enterprise.container.common.impl.QueryWrapper.getResultList(QueryWrapper.java:84)
>>
>> at com
>> .dobe.app.backingbeans.TopPanelBackingBean.completeSearchBar(TopPanelBackingBean.java:289)
>>
>> at com
>> .dobe.app.backingbeans.TopPanelBackingBean$Proxy$_$$_WeldClientProxy.completeSearchBar(Unknown<arrow-10x10.png> Source)
>>
>> at sun
>> .reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>
>> at sun
>> .reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>
>> at sun
>> .reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>
>> at java
>> .lang.reflect.Method.invoke(Method.java:606)
>>
>> at com
>> .sun.el.parser.AstValue.invoke(AstValue.java:275)
>>
>> at com
>> .sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
>>
>> at org
>> .jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
>>
>> at org
>> .jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
>>
>> at com
>> .sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
>> ... 45 more
>> The weird thing is that I can persist them just fine, but not load them. For example, if I do something like:
>>
>> LocationBean loc = new LocationBean();
>>
>> loc
>> .setLocation(new GeometryFactory.createPoint(new Coordinate(lon, lat));
>> // persist to db...
>> The point is correctly stored correctly in the Postgresql database and querying it works. Only when I load it, it doesn't work.
>>
>> I can also load other fields from the class, besides the location field. So for instance:
>>
>> Query query = em.createQuery("SELECT l.id from LocationBean l  WHERE within(v.location, :filter) = true", Long.class);
>> would work, but:
>>
>> Query query = em.createQuery("SELECT l from LocationBean l  WHERE within(v.location, :filter) = true", LocationBean.class);
>> would not.
>>
>> These are the dependencies in my pom.xml:
>>
>>      <dependency>
>>
>>          
>> <groupId>org.hibernate</groupId>
>>
>>          
>> <artifactId>hibernate-core</artifactId>
>>
>>          
>> <version>4.3.5.Final</version>
>>
>>      
>> </dependency>
>>
>>      
>> <dependency>
>>
>>          
>> <groupId>org.hibernate</groupId>
>>
>>          
>> <artifactId>hibernate-entitymanager</artifactId>
>>
>>          
>> <version>4.3.5.Final</version>
>>
>>      
>> </dependency>
>>
>>      
>> <dependency>
>>
>>          
>> <groupId>org.hibernate</groupId>
>>
>>          
>> <artifactId>hibernate-spatial</artifactId>
>>
>>          
>> <version>4.3-SNAPSHOT</version>
>>
>>      
>> </dependency>
>>
>>      
>> <dependency>
>>
>>          
>> <groupId>postgresql</groupId>
>>
>>          
>> <artifactId>postgresql</artifactId>
>>
>>          
>> <version>9.2-1002.jdbc4</version>
>>
>>      
>> </dependency>
>>
>>      
>> <dependency>
>>
>>          
>> <groupId>org.postgis</groupId>
>>
>>          
>> <artifactId>postgis-jdbc</artifactId>
>>
>>          
>> <version>1.5.2</version>
>>
>>      
>> </dependency>
>> Any ideas what I could try? I have a workaround solution at the moment, where I only use the persisted GeometryType for querying, but don't ever load it into a java object, but I am not happy with that solution. Thanks!
>> Cheers,
>> Dominik
>> _______________________________________________
>> 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

_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Reply | Threaded
Open this post in threaded view
|

Re: can't load Entities with field of type org.hibernate.spatial.GeometryType

DoBe
In reply to this post by Karel Maesen
Fixed it! Thanks for your help, I wouldn't have figured it out on my own.

The problem was that I only included postgis-jbbc in my pom.xml, but I
also needed to place a copy of that library in the Glassfish library
directory (glassfish_base/domain/domain1/lib/ext).

I think in web.xml, there is an option to load jars from within
applications with the same classloader. I remember I wanted to use an
updated Mojarra in an app once, but I got other errors when setting the
delegate classloader to true. Anyways, its working now with putting the
jar in the Glassfish library folder.

Cheers,
Dominik

On 24/04/2014 17:03, Karel Maesen wrote:

> Hi Dominik,
>
> It seems to me dat the Postgis JDBC extension jar is not available in the classloader. Kan you check that it is on the classpath, and loaded by the proper classloader?
>
> Classloader issues are common when using a J2EE container where the database connection is in some way or another managed by the container. The JDBC and the Postgis.jar need to be loaded by the same classloader. The fact that you get a PGobject where a PGgeometry is expected is a common symptom that this is not happening in your application.
>
> Regards,
>
> Karel
>
> On 24 Apr 2014, at 17:47, Dominik Beste <[hidden email]> wrote:
>
>> Hi,
>>
>> (I also posted this on stackoverflow at: http://stackoverflow.com/questions/23270071/cant-convert-object-of-type-org-postgresql-util-pgobject)
>>
>> I have a problem with using Hibernate Spatial and PostGIS. I have an entity with a field like this:
>> public class LocationBean {
>>
>>    
>> @
>> Id
>>    
>> @GeneratedValue(strategy = GenerationType.AUTO)
>>
>>    private long id
>> ;
>>
>>
>>    
>> @Type(type = "org.hibernate.spatial.GeometryType")
>>
>>    private Point location
>> ;
>> }
>> The problem I have is that I can't load any of these entities from the database, unless location is null for that entity. If it is not null, I get the following error:
>>
>> Exception: Can
>> 't convert object of type org.postgresql.util.PGobject
>> javax.el.ELException: /protected/topPanel/searchBar.xhtml @27,57 completeMethod="#{toppanelbb.completeSearchBar}": java.lang.IllegalArgumentException: Can'
>> t convert object of type org.postgresql.util.
>> PGobject
>> at com
>> .sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:111)
>>
>> at org
>> .primefaces.component.autocomplete.AutoComplete.broadcast(AutoComplete.java:337)
>>
>> at javax
>> .faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
>>
>> at javax
>> .faces.component.UIViewRoot.processDecodes(UIViewRoot.java:931)
>>
>> at com
>> .sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
>>
>> at com
>> .sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
>>
>> at com
>> .sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
>>
>> at javax
>> .faces.webapp.FacesServlet.service(FacesServlet.java:646)
>>
>> at org
>> .apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
>>
>> at org
>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:344)
>>
>> at org
>> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
>>
>> at org
>> .primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:70)
>>
>> at org
>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
>>
>> at org
>> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
>>
>> at org
>> .glassfish.tyrus.servlet.TyrusServletFilter.doFilter(TyrusServletFilter.java:253)
>>
>> at org
>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
>>
>> at org
>> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
>>
>> at org
>> .ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:205)
>>
>> at org
>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
>>
>> at org
>> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
>>
>> at org
>> .apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316)
>>
>> at org
>> .apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
>>
>> at org
>> .apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
>>
>> at org
>> .apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
>>
>> at com
>> .sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
>>
>> at org
>> .apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
>>
>> at org
>> .apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
>>
>> at org
>> .apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
>>
>> at com
>> .sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
>>
>> at org
>> .glassfish.grizzly.http.server<arrow-10x10.png>.HttpHandler.runService(HttpHandler.java:191)
>>
>> at org
>> .glassfish.grizzly.http.server<arrow-10x10.png>.HttpHandler.doHandle(HttpHandler.java:168)
>>
>> at org
>> .glassfish.grizzly.http.server<arrow-10x10.png>.HttpServerFilter.handleRead(HttpServerFilter.java:189)
>>
>> at org
>> .glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
>>
>> at org
>> .glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
>>
>> at org
>> .glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
>>
>> at org
>> .glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
>>
>> at org
>> .glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
>>
>> at org
>> .glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
>>
>> at org
>> .glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
>>
>> at org
>> .glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
>>
>> at org
>> .glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
>>
>> at org
>> .glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
>>
>> at org
>> .glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
>>
>> at org
>> .glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
>>
>> at org
>> .glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
>>
>> at java
>> .lang.Thread.run(Thread.java:744)
>>
>> Caused
>> by: java.lang.IllegalArgumentException: Can't convert object of type org.postgresql.util.
>> PGobject
>> at org
>> .hibernate.spatial.dialect.postgis.PGGeometryValueExtractor.toJTS(PGGeometryValueExtractor.java:113)
>>
>> at org
>> .hibernate.spatial.dialect.AbstractJTSGeometryValueExtractor.doExtract(AbstractJTSGeometryValueExtractor.java:50)
>>
>> at org
>> .hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64)
>>
>> at org
>> .hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:267)
>>
>> at org
>> .hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:263)
>>
>> at org
>> .hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:253)
>>
>> at org
>> .hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:338)
>>
>> at org
>> .hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2969)
>>
>> at org
>> .hibernate.loader.Loader.loadFromResultSet(Loader.java:1695)
>>
>> at org
>> .hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1627)
>>
>> at org
>> .hibernate.loader.Loader.getRow(Loader.java:1514)
>>
>> at org
>> .hibernate.loader.Loader.getRowFromResultSet(Loader.java:725)
>>
>> at org
>> .hibernate.loader.Loader.processResultSet(Loader.java:952)
>>
>> at org
>> .hibernate.loader.Loader.doQuery(Loader.java:920)
>>
>> at org
>> .hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:354)
>>
>> at org
>> .hibernate.loader.Loader.doList(Loader.java:2553)
>>
>> at org
>> .hibernate.loader.Loader.doList(Loader.java:2539)
>>
>> at org
>> .hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2369)
>>
>> at org
>> .hibernate.loader.Loader.list(Loader.java:2364)
>>
>> at org
>> .hibernate.loader.hql.QueryLoader.list(QueryLoader.java:496)
>>
>> at org
>> .hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:387)
>>
>> at org
>> .hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:231)
>>
>> at org
>> .hibernate.internal.SessionImpl.list(SessionImpl.java:1264)
>>
>> at org
>> .hibernate.internal.QueryImpl.list(QueryImpl.java:103)
>>
>> at org
>> .hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:573)
>>
>> at org
>> .hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:449)
>>
>> at com
>> .sun.enterprise.container.common.impl.QueryWrapper.getResultList(QueryWrapper.java:84)
>>
>> at com
>> .dobe.app.backingbeans.TopPanelBackingBean.completeSearchBar(TopPanelBackingBean.java:289)
>>
>> at com
>> .dobe.app.backingbeans.TopPanelBackingBean$Proxy$_$$_WeldClientProxy.completeSearchBar(Unknown<arrow-10x10.png> Source)
>>
>> at sun
>> .reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>
>> at sun
>> .reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>
>> at sun
>> .reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>
>> at java
>> .lang.reflect.Method.invoke(Method.java:606)
>>
>> at com
>> .sun.el.parser.AstValue.invoke(AstValue.java:275)
>>
>> at com
>> .sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
>>
>> at org
>> .jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
>>
>> at org
>> .jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
>>
>> at com
>> .sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
>> ... 45 more
>> The weird thing is that I can persist them just fine, but not load them. For example, if I do something like:
>>
>> LocationBean loc = new LocationBean();
>>
>> loc
>> .setLocation(new GeometryFactory.createPoint(new Coordinate(lon, lat));
>> // persist to db...
>> The point is correctly stored correctly in the Postgresql database and querying it works. Only when I load it, it doesn't work.
>>
>> I can also load other fields from the class, besides the location field. So for instance:
>>
>> Query query = em.createQuery("SELECT l.id from LocationBean l  WHERE within(v.location, :filter) = true", Long.class);
>> would work, but:
>>
>> Query query = em.createQuery("SELECT l from LocationBean l  WHERE within(v.location, :filter) = true", LocationBean.class);
>> would not.
>>
>> These are the dependencies in my pom.xml:
>>
>>      <dependency>
>>
>>          
>> <groupId>org.hibernate</groupId>
>>
>>          
>> <artifactId>hibernate-core</artifactId>
>>
>>          
>> <version>4.3.5.Final</version>
>>
>>      
>> </dependency>
>>
>>      
>> <dependency>
>>
>>          
>> <groupId>org.hibernate</groupId>
>>
>>          
>> <artifactId>hibernate-entitymanager</artifactId>
>>
>>          
>> <version>4.3.5.Final</version>
>>
>>      
>> </dependency>
>>
>>      
>> <dependency>
>>
>>          
>> <groupId>org.hibernate</groupId>
>>
>>          
>> <artifactId>hibernate-spatial</artifactId>
>>
>>          
>> <version>4.3-SNAPSHOT</version>
>>
>>      
>> </dependency>
>>
>>      
>> <dependency>
>>
>>          
>> <groupId>postgresql</groupId>
>>
>>          
>> <artifactId>postgresql</artifactId>
>>
>>          
>> <version>9.2-1002.jdbc4</version>
>>
>>      
>> </dependency>
>>
>>      
>> <dependency>
>>
>>          
>> <groupId>org.postgis</groupId>
>>
>>          
>> <artifactId>postgis-jdbc</artifactId>
>>
>>          
>> <version>1.5.2</version>
>>
>>      
>> </dependency>
>> Any ideas what I could try? I have a workaround solution at the moment, where I only use the persisted GeometryType for querying, but don't ever load it into a java object, but I am not happy with that solution. Thanks!
>> Cheers,
>> Dominik
>> _______________________________________________
>> 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

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