hibernate - Received object of type org.postgresql.util.PGobject -
i can insert geometry data database code, can query data using sql editor, pgadmin iii. can't retrieve geometry data code. every attempt ends with: "received object of type org.postgresql.util.pgobject". running simple query test if 2 geometry values equal, error.
2017-09-11 19:04:47,771 warning [javax.enterprise.resource.webcontainer.jsf.lifecycle] (default task-37) /welcomeprimefaces.xhtml @46,106 actionlistener="#{controlador.testar()}": java.lang.illegalstateexception: received object of type org.postgresql.util.pgobject: javax.el.elexception: /welcomeprimefaces.xhtml @46,106 actionlistener="#{controlador.testar()}": java.lang.illegalstateexception: received object of type org.postgresql.util.pgobject @ com.sun.faces.facelets.el.tagmethodexpression.invoke(tagmethodexpression.java:111) @ javax.faces.event.methodexpressionactionlistener.processaction(methodexpressionactionlistener.java:147) @ javax.faces.event.actionevent.processlistener(actionevent.java:88) @ javax.faces.component.uicomponentbase.broadcast(uicomponentbase.java:814) @ javax.faces.component.uicommand.broadcast(uicommand.java:300) @ javax.faces.component.uiviewroot.broadcastevents(uiviewroot.java:790) @ javax.faces.component.uiviewroot.processapplication(uiviewroot.java:1282) @ com.sun.faces.lifecycle.invokeapplicationphase.execute(invokeapplicationphase.java:81) @ com.sun.faces.lifecycle.phase.dophase(phase.java:101) @ com.sun.faces.lifecycle.lifecycleimpl.execute(lifecycleimpl.java:198) @ javax.faces.webapp.facesservlet.service(facesservlet.java:658) @ io.undertow.servlet.handlers.servlethandler.handlerequest(servlethandler.java:85) @ io.undertow.servlet.handlers.security.servletsecurityrolehandler.handlerequest(servletsecurityrolehandler.java:62) @ io.undertow.servlet.handlers.servletdispatchinghandler.handlerequest(servletdispatchinghandler.java:36) @ org.wildfly.extension.undertow.security.securitycontextassociationhandler.handlerequest(securitycontextassociationhandler.java:78) @ io.undertow.server.handlers.predicatehandler.handlerequest(predicatehandler.java:43) @ io.undertow.servlet.handlers.security.sslinformationassociationhandler.handlerequest(sslinformationassociationhandler.java:131) @ io.undertow.servlet.handlers.security.servletauthenticationcallhandler.handlerequest(servletauthenticationcallhandler.java:57) @ io.undertow.server.handlers.predicatehandler.handlerequest(predicatehandler.java:43) @ io.undertow.security.handlers.abstractconfidentialityhandler.handlerequest(abstractconfidentialityhandler.java:46) @ io.undertow.servlet.handlers.security.servletconfidentialityconstrainthandler.handlerequest(servletconfidentialityconstrainthandler.java:64) @ io.undertow.security.handlers.authenticationmechanismshandler.handlerequest(authenticationmechanismshandler.java:60) @ io.undertow.servlet.handlers.security.cachedauthenticatedsessionhandler.handlerequest(cachedauthenticatedsessionhandler.java:77) @ io.undertow.security.handlers.notificationreceiverhandler.handlerequest(notificationreceiverhandler.java:50) @ io.undertow.security.handlers.abstractsecuritycontextassociationhandler.handlerequest(abstractsecuritycontextassociationhandler.java:43) @ io.undertow.server.handlers.predicatehandler.handlerequest(predicatehandler.java:43) @ org.wildfly.extension.undertow.security.jacc.jacccontextidhandler.handlerequest(jacccontextidhandler.java:61) @ io.undertow.server.handlers.predicatehandler.handlerequest(predicatehandler.java:43) @ org.wildfly.extension.undertow.deployment.globalrequestcontrollerhandler.handlerequest(globalrequestcontrollerhandler.java:68) @ io.undertow.server.handlers.predicatehandler.handlerequest(predicatehandler.java:43) @ io.undertow.servlet.handlers.servletinitialhandler.handlefirstrequest(servletinitialhandler.java:292) @ io.undertow.servlet.handlers.servletinitialhandler.access$100(servletinitialhandler.java:81) @ io.undertow.servlet.handlers.servletinitialhandler$2.call(servletinitialhandler.java:138) @ io.undertow.servlet.handlers.servletinitialhandler$2.call(servletinitialhandler.java:135) @ io.undertow.servlet.core.servletrequestcontextthreadsetupaction$1.call(servletrequestcontextthreadsetupaction.java:48) @ io.undertow.servlet.core.contextclassloadersetupaction$1.call(contextclassloadersetupaction.java:43) @ org.wildfly.extension.undertow.security.securitycontextthreadsetupaction.lambda$create$0(securitycontextthreadsetupaction.java:105) @ org.wildfly.extension.undertow.deployment.undertowdeploymentinfoservice$undertowthreadsetupaction.lambda$create$0(undertowdeploymentinfoservice.java:1508) @ org.wildfly.extension.undertow.deployment.undertowdeploymentinfoservice$undertowthreadsetupaction.lambda$create$0(undertowdeploymentinfoservice.java:1508) @ org.wildfly.extension.undertow.deployment.undertowdeploymentinfoservice$undertowthreadsetupaction.lambda$create$0(undertowdeploymentinfoservice.java:1508) @ org.wildfly.extension.undertow.deployment.undertowdeploymentinfoservice$undertowthreadsetupaction.lambda$create$0(undertowdeploymentinfoservice.java:1508) @ org.wildfly.extension.undertow.deployment.undertowdeploymentinfoservice$undertowthreadsetupaction.lambda$create$0(undertowdeploymentinfoservice.java:1508) @ io.undertow.servlet.handlers.servletinitialhandler.dispatchrequest(servletinitialhandler.java:272) @ io.undertow.servlet.handlers.servletinitialhandler.access$000(servletinitialhandler.java:81) @ io.undertow.servlet.handlers.servletinitialhandler$1.handlerequest(servletinitialhandler.java:104) @ io.undertow.server.connectors.executeroothandler(connectors.java:326) @ io.undertow.server.httpserverexchange$1.run(httpserverexchange.java:812) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1149) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:624) @ java.lang.thread.run(thread.java:748) caused by: java.lang.illegalstateexception: received object of type org.postgresql.util.pgobject @ org.hibernate.spatial.dialect.postgis.pggeometrytypedescriptor.togeometry(pggeometrytypedescriptor.java:123) @ org.hibernate.spatial.dialect.postgis.pggeometrytypedescriptor$2.doextract(pggeometrytypedescriptor.java:87) @ org.hibernate.type.descriptor.sql.basicextractor.extract(basicextractor.java:47) @ org.hibernate.type.abstractstandardbasictype.nullsafeget(abstractstandardbasictype.java:235) @ org.hibernate.type.abstractstandardbasictype.nullsafeget(abstractstandardbasictype.java:231) @ org.hibernate.type.abstractstandardbasictype.nullsafeget(abstractstandardbasictype.java:222) @ org.hibernate.type.abstractstandardbasictype.hydrate(abstractstandardbasictype.java:296) @ org.hibernate.persister.entity.abstractentitypersister.hydrate(abstractentitypersister.java:2840) @ org.hibernate.loader.loader.loadfromresultset(loader.java:1735) @ org.hibernate.loader.loader.instancenotyetloaded(loader.java:1661) @ org.hibernate.loader.loader.getrow(loader.java:1550) @ org.hibernate.loader.loader.getrowfromresultset(loader.java:733) @ org.hibernate.loader.loader.processresultset(loader.java:978) @ org.hibernate.loader.loader.doquery(loader.java:936) @ org.hibernate.loader.loader.doqueryandinitializenonlazycollections(loader.java:342) @ org.hibernate.loader.loader.dolist(loader.java:2622) @ org.hibernate.loader.loader.dolist(loader.java:2605) @ org.hibernate.loader.loader.listignorequerycache(loader.java:2434) @ org.hibernate.loader.loader.list(loader.java:2429) @ org.hibernate.loader.hql.queryloader.list(queryloader.java:501) @ org.hibernate.hql.internal.ast.querytranslatorimpl.list(querytranslatorimpl.java:371) @ org.hibernate.engine.query.spi.hqlqueryplan.performlist(hqlqueryplan.java:216) @ org.hibernate.internal.sessionimpl.list(sessionimpl.java:1339) @ org.hibernate.internal.queryimpl.list(queryimpl.java:87) @ org.hibernate.jpa.internal.queryimpl.list(queryimpl.java:606) @ org.hibernate.jpa.internal.queryimpl.getresultlist(queryimpl.java:483) @ org.jboss.as.jpa.container.querynontxinvocationdetacher.getresultlist(querynontxinvocationdetacher.java:58) @ br.gov.rio.iplanrio.projetox.controle.controlador.testar(controlador.java:121) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:498) @ javax.el.elutil.invokemethod(elutil.java:311) @ javax.el.beanelresolver.invoke(beanelresolver.java:415) @ javax.el.compositeelresolver.invoke(compositeelresolver.java:256) @ com.sun.el.parser.astvalue.invoke(astvalue.java:285) @ com.sun.el.methodexpressionimpl.invoke(methodexpressionimpl.java:304) @ org.jboss.weld.util.el.forwardingmethodexpression.invoke(forwardingmethodexpression.java:40) @ org.jboss.weld.el.weldmethodexpression.invoke(weldmethodexpression.java:50) @ org.jboss.weld.util.el.forwardingmethodexpression.invoke(forwardingmethodexpression.java:40) @ org.jboss.weld.el.weldmethodexpression.invoke(weldmethodexpression.java:50) @ com.sun.faces.facelets.el.tagmethodexpression.invoke(tagmethodexpression.java:105) ... 49 more 2017-09-11 19:04:47,800 severe [javax.enterprise.resource.webcontainer.jsf.context] (default task-37) java.lang.illegalstateexception: received object of type org.postgresql.util.pgobject @ org.hibernate.spatial.dialect.postgis.pggeometrytypedescriptor.togeometry(pggeometrytypedescriptor.java:123) @ org.hibernate.spatial.dialect.postgis.pggeometrytypedescriptor$2.doextract(pggeometrytypedescriptor.java:87) @ org.hibernate.type.descriptor.sql.basicextractor.extract(basicextractor.java:47) @ org.hibernate.type.abstractstandardbasictype.nullsafeget(abstractstandardbasictype.java:235) @ org.hibernate.type.abstractstandardbasictype.nullsafeget(abstractstandardbasictype.java:231) @ org.hibernate.type.abstractstandardbasictype.nullsafeget(abstractstandardbasictype.java:222) @ org.hibernate.type.abstractstandardbasictype.hydrate(abstractstandardbasictype.java:296) @ org.hibernate.persister.entity.abstractentitypersister.hydrate(abstractentitypersister.java:2840) @ org.hibernate.loader.loader.loadfromresultset(loader.java:1735) @ org.hibernate.loader.loader.instancenotyetloaded(loader.java:1661) @ org.hibernate.loader.loader.getrow(loader.java:1550) @ org.hibernate.loader.loader.getrowfromresultset(loader.java:733) @ org.hibernate.loader.loader.processresultset(loader.java:978) @ org.hibernate.loader.loader.doquery(loader.java:936) @ org.hibernate.loader.loader.doqueryandinitializenonlazycollections(loader.java:342) @ org.hibernate.loader.loader.dolist(loader.java:2622) @ org.hibernate.loader.loader.dolist(loader.java:2605) @ org.hibernate.loader.loader.listignorequerycache(loader.java:2434) @ org.hibernate.loader.loader.list(loader.java:2429) @ org.hibernate.loader.hql.queryloader.list(queryloader.java:501) @ org.hibernate.hql.internal.ast.querytranslatorimpl.list(querytranslatorimpl.java:371) @ org.hibernate.engine.query.spi.hqlqueryplan.performlist(hqlqueryplan.java:216) @ org.hibernate.internal.sessionimpl.list(sessionimpl.java:1339) @ org.hibernate.internal.queryimpl.list(queryimpl.java:87) @ org.hibernate.jpa.internal.queryimpl.list(queryimpl.java:606) @ org.hibernate.jpa.internal.queryimpl.getresultlist(queryimpl.java:483) @ org.jboss.as.jpa.container.querynontxinvocationdetacher.getresultlist(querynontxinvocationdetacher.java:58) @ br.gov.rio.iplanrio.projetox.controle.controlador.testar(controlador.java:121) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:498) @ javax.el.elutil.invokemethod(elutil.java:311) @ javax.el.beanelresolver.invoke(beanelresolver.java:415) @ javax.el.compositeelresolver.invoke(compositeelresolver.java:256) @ com.sun.el.parser.astvalue.invoke(astvalue.java:285) @ com.sun.el.methodexpressionimpl.invoke(methodexpressionimpl.java:304) @ org.jboss.weld.util.el.forwardingmethodexpression.invoke(forwardingmethodexpression.java:40) @ org.jboss.weld.el.weldmethodexpression.invoke(weldmethodexpression.java:50) @ org.jboss.weld.util.el.forwardingmethodexpression.invoke(forwardingmethodexpression.java:40) @ org.jboss.weld.el.weldmethodexpression.invoke(weldmethodexpression.java:50) @ com.sun.faces.facelets.el.tagmethodexpression.invoke(tagmethodexpression.java:105) @ javax.faces.event.methodexpressionactionlistener.processaction(methodexpressionactionlistener.java:147) @ javax.faces.event.actionevent.processlistener(actionevent.java:88) @ javax.faces.component.uicomponentbase.broadcast(uicomponentbase.java:814) @ javax.faces.component.uicommand.broadcast(uicommand.java:300) @ javax.faces.component.uiviewroot.broadcastevents(uiviewroot.java:790) @ javax.faces.component.uiviewroot.processapplication(uiviewroot.java:1282) @ com.sun.faces.lifecycle.invokeapplicationphase.execute(invokeapplicationphase.java:81) @ com.sun.faces.lifecycle.phase.dophase(phase.java:101) @ com.sun.faces.lifecycle.lifecycleimpl.execute(lifecycleimpl.java:198) @ javax.faces.webapp.facesservlet.service(facesservlet.java:658) @ io.undertow.servlet.handlers.servlethandler.handlerequest(servlethandler.java:85) @ io.undertow.servlet.handlers.security.servletsecurityrolehandler.handlerequest(servletsecurityrolehandler.java:62) @ io.undertow.servlet.handlers.servletdispatchinghandler.handlerequest(servletdispatchinghandler.java:36) @ org.wildfly.extension.undertow.security.securitycontextassociationhandler.handlerequest(securitycontextassociationhandler.java:78) @ io.undertow.server.handlers.predicatehandler.handlerequest(predicatehandler.java:43) @ io.undertow.servlet.handlers.security.sslinformationassociationhandler.handlerequest(sslinformationassociationhandler.java:131) @ io.undertow.servlet.handlers.security.servletauthenticationcallhandler.handlerequest(servletauthenticationcallhandler.java:57) @ io.undertow.server.handlers.predicatehandler.handlerequest(predicatehandler.java:43) @ io.undertow.security.handlers.abstractconfidentialityhandler.handlerequest(abstractconfidentialityhandler.java:46) @ io.undertow.servlet.handlers.security.servletconfidentialityconstrainthandler.handlerequest(servletconfidentialityconstrainthandler.java:64) @ io.undertow.security.handlers.authenticationmechanismshandler.handlerequest(authenticationmechanismshandler.java:60) @ io.undertow.servlet.handlers.security.cachedauthenticatedsessionhandler.handlerequest(cachedauthenticatedsessionhandler.java:77) @ io.undertow.security.handlers.notificationreceiverhandler.handlerequest(notificationreceiverhandler.java:50) @ io.undertow.security.handlers.abstractsecuritycontextassociationhandler.handlerequest(abstractsecuritycontextassociationhandler.java:43) @ io.undertow.server.handlers.predicatehandler.handlerequest(predicatehandler.java:43) @ org.wildfly.extension.undertow.security.jacc.jacccontextidhandler.handlerequest(jacccontextidhandler.java:61) @ io.undertow.server.handlers.predicatehandler.handlerequest(predicatehandler.java:43) @ org.wildfly.extension.undertow.deployment.globalrequestcontrollerhandler.handlerequest(globalrequestcontrollerhandler.java:68) @ io.undertow.server.handlers.predicatehandler.handlerequest(predicatehandler.java:43) @ io.undertow.servlet.handlers.servletinitialhandler.handlefirstrequest(servletinitialhandler.java:292) @ io.undertow.servlet.handlers.servletinitialhandler.access$100(servletinitialhandler.java:81) @ io.undertow.servlet.handlers.servletinitialhandler$2.call(servletinitialhandler.java:138) @ io.undertow.servlet.handlers.servletinitialhandler$2.call(servletinitialhandler.java:135) @ io.undertow.servlet.core.servletrequestcontextthreadsetupaction$1.call(servletrequestcontextthreadsetupaction.java:48) @ io.undertow.servlet.core.contextclassloadersetupaction$1.call(contextclassloadersetupaction.java:43) @ org.wildfly.extension.undertow.security.securitycontextthreadsetupaction.lambda$create$0(securitycontextthreadsetupaction.java:105) @ org.wildfly.extension.undertow.deployment.undertowdeploymentinfoservice$undertowthreadsetupaction.lambda$create$0(undertowdeploymentinfoservice.java:1508) @ org.wildfly.extension.undertow.deployment.undertowdeploymentinfoservice$undertowthreadsetupaction.lambda$create$0(undertowdeploymentinfoservice.java:1508) @ org.wildfly.extension.undertow.deployment.undertowdeploymentinfoservice$undertowthreadsetupaction.lambda$create$0(undertowdeploymentinfoservice.java:1508) @ org.wildfly.extension.undertow.deployment.undertowdeploymentinfoservice$undertowthreadsetupaction.lambda$create$0(undertowdeploymentinfoservice.java:1508) @ org.wildfly.extension.undertow.deployment.undertowdeploymentinfoservice$undertowthreadsetupaction.lambda$create$0(undertowdeploymentinfoservice.java:1508) @ io.undertow.servlet.handlers.servletinitialhandler.dispatchrequest(servletinitialhandler.java:272) @ io.undertow.servlet.handlers.servletinitialhandler.access$000(servletinitialhandler.java:81) @ io.undertow.servlet.handlers.servletinitialhandler$1.handlerequest(servletinitialhandler.java:104) @ io.undertow.server.connectors.executeroothandler(connectors.java:326) @ io.undertow.server.httpserverexchange$1.run(httpserverexchange.java:812) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1149) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:624) @ java.lang.thread.run(thread.java:748)
i'm using: - hibernate 5.2 - postgresql 9.6 - postgis 2.3 - jdbc driver postgresql 42.1.4 - wildfly 11 (cr1)
here model class:
import java.io.serializable; import javax.persistence.entity; import javax.persistence.generatedvalue; import javax.persistence.generationtype; import javax.persistence.id; import com.vividsolutions.jts.geom.point; import com.vividsolutions.jts.geom.geometry; import com.vividsolutions.jts.geom.linestring; import com.vividsolutions.jts.geom.polygon; import javax.persistence.column; @entity public class pontodeinteresse implements serializable { private static final long serialversionuid = 1l; @id @generatedvalue(strategy = generationtype.sequence) private long id; private string descricao; @column(columndefinition = "geometry(point,4326)") private point ponto; @column(columndefinition = "geometry(linestring,4326)") private linestring linha; @column(columndefinition = "geometry(geometry,4326)") private geometry geometry; @column(columndefinition = "geometry(polygon,4326)") private polygon poligono;
the pom file:
<dependencies> <dependency> <groupid>org.primefaces</groupid> <artifactid>primefaces</artifactid> <version>6.1</version> </dependency> <dependency> <groupid>javax</groupid> <artifactid>javaee-web-api</artifactid> <version>6.0</version> <scope>provided</scope> </dependency> <dependency> <groupid>com.vividsolutions</groupid> <artifactid>jts</artifactid> <version>1.13</version> </dependency> <dependency> <groupid>org.hibernate</groupid> <artifactid>hibernate-spatial</artifactid> <version>5.2.10.final</version> </dependency> <dependency> <groupid>org.hibernate</groupid> <artifactid>hibernate-core</artifactid> <version>5.2.10.final</version> </dependency> <dependency> <groupid>org.hibernate</groupid> <artifactid>hibernate-entitymanager</artifactid> <version>5.2.10.final</version> </dependency> <dependency> <groupid>dom4j</groupid> <artifactid>dom4j</artifactid> <version>1.6.1</version> <scope>provided</scope> </dependency> </dependencies>
inside persistence.xml file, i'm using dialect property:
<property name="hibernate.dialect" value="org.hibernate.spatial.dialect.postgis.postgispg95dialect"/>
ps: have tried postgisdialect
finally, method simple test query:
public void testar() { try { geometryfactory gf = new geometryfactory(); linearring shell = gf.createlinearring(new coordinate[] { new coordinate(-43.56006145477295,-22.8861191211294), new coordinate(-43.55607032775879,-22.8861191211294), new coordinate(-43.55607032775879,-22.88279796969916), new coordinate(-43.56006145477295,-22.88279796969916), new coordinate(-43.56006145477295,-22.8861191211294)}); linearring[] holes = new linearring[0]; polygon polygon = gf.createpolygon(shell, holes); polygon.setsrid(4326); query q = entitymanager.createquery("from pontodeinteresse equals(geometry, :geo) = true").setparameter("geo", polygon); list<pontodeinteresse> pontos = q.getresultlist(); } catch(exception e) { system.out.println(e.getmessage()); }//try }
i'm lost here, running out of ideas. please help. thanks
you need add postgis, hibernate-spatial , other related libs wildfly before deploying application, because hibernate using bundled wildfly other libraries bundled war, using different classloaders.
if check this code can see cast correct, , error message make no sense, tipically issue classloaders.
to fix issue need add libs wildfly, can do:
cd $jboss_path/modules/system/layers/base/org/hibernate/main mvn dependency:copy -dartifact=org.hibernate:hibernate-spatial:5.0.7.final:jar -doutputdirectory=. mvn dependency:copy -dartifact=org.geolatte:geolatte-geom:1.0.1:jar -doutputdirectory=. mvn dependency:copy -dartifact=com.vividsolutions:jts:1.13:jar -doutputdirectory=.
edit module.xml
file add deps:
<resource-root path="hibernate-spatial-5.0.7.final.jar"/> <resource-root path="jts-1.13.jar"/> <resource-root path="geolatte-geom-1.0.1.jar"/>
and in dependencies tag, add:
<module name="org.slf4j"/>
also if using postgresql, need add in dependencies tag:
<module name="org.postgresql"/>
use correct version in mvn
command download correct jar.
Comments
Post a Comment