|
|
|
jdeprez
|
Hi,
I'm having trouble configuring postgis on my server. I adapted the instructions from the hibernate spatial tutorial to my application, which uses Seam / Icefaces frameworks and runs on a JBoss 4.2.3.GA application server. I don't use xml mapping files, my entity classes are annotated. @Column(name = "cpn_location") @Type(type="org.hibernatespatial.GeometryUserType") public Point getCpnLocation() { return this.cpnLocation; } I have installed PostGis 1.3.5 on postgresql 8.3. The jdbc driver is postgresql-8.3-603.jdbc4.jar. When starting the server I can see that it uses the Postgis dialect. The geometry column accepts 2-dimensional points with SRID(4326). From my application I can store Point objects in this column without problems. But whenever I run a query that reads the table with the geometry field, I get this error: 15:35:03,727 ERROR [application] java.lang.IllegalArgumentException: Can't convert object of type org.postgis.PGgeometry javax.faces.el.EvaluationException: java.lang.IllegalArgumentException: Can't convert object of type org.postgis.PGgeometry at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102) at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) at javax.faces.component.UICommand.broadcast(UICommand.java:387) at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:755) at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) at com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:17) at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.renderCycle(ReceiveSendUpdates.java:94) at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.service(ReceiveSendUpdates.java:54) at com.icesoft.faces.webapp.http.core.RequestVerifier.service(RequestVerifier.java:26) at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:24) at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:160) at com.icesoft.faces.webapp.http.servlet.SessionDispatcher$1.service(SessionDispatcher.java:38) ... ... Caused by: java.lang.IllegalArgumentException: Can't convert object of type org.postgis.PGgeometry at org.hibernatespatial.postgis.PGGeometryUserType.convert2JTS(PGGeometryUserType.java:123) at org.hibernatespatial.AbstractDBGeometryType.nullSafeGet(AbstractDBGeometryType.java:127) at org.hibernatespatial.GeometryUserType.nullSafeGet(GeometryUserType.java:170) at org.hibernate.type.CustomType.nullSafeGet(CustomType.java:105) at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81) at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2096) at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1380) at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1308) at org.hibernate.loader.Loader.getRow(Loader.java:1206) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:580) ... ... Any idea of what could be the problem? _______________________________________________ hibernatespatial-users mailing list [hidden email] http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users |
||||||||||||||||
|
Karel Maesen
|
Hi,
I think the problem is that you have more than one postgis.jar on the classpath, or that the one postgis.jar is configured on the class path of more than one class loader. This exception is thrown when the conversion code determines that the object it receives (from Hibernate, so indirectly from JDBC) is neither an instance of org.postgis.PGgeometry nor a org.postgis.Geometry. In that case it throws an exception because it doesn't know how to convert the object into a JTS Geometry instance. The exception reports the class of the object as reported by the getClass() method. Now in your case the exception reports that the the instance it can't convert is of class org.postgis.PGgeometry. But this is exactly the class for which is tested (in line 85)! This implies that the type of the object passed to the conversion method is considered by the Java runtime as completely different as the type tested for, although both types are org.postgis.PGgeometry. As far as I know this can only happen when the postgis.jar (that defines PGgeometry) is loaded by two different class loaders. So I would check for multiple postgis jars on the classpath of the JBoss app. server, the JRE and the web app. Hope this helps. Regards, Karel Maesen On 29 Dec 2008, at 15:40, Jonne wrote: > Hi, > > I'm having trouble configuring postgis on my server. I adapted the > instructions from the hibernate spatial tutorial to my application, > which uses Seam / Icefaces frameworks and runs on a JBoss 4.2.3.GA > application server. I don't use xml mapping files, my entity > classes are annotated. > > @Column(name = "cpn_location") > @Type(type="org.hibernatespatial.GeometryUserType") > public Point getCpnLocation() { > return this.cpnLocation; > } > > I have installed PostGis 1.3.5 on postgresql 8.3. The jdbc driver > is postgresql-8.3-603.jdbc4.jar. When starting the server I can see > that it uses the Postgis dialect. > > The geometry column accepts 2-dimensional points with SRID(4326). > From my application I can store Point objects in this column > without problems. > > But whenever I run a query that reads the table with the geometry > field, I get this error: > > 15:35:03,727 ERROR [application] > java.lang.IllegalArgumentException: Can't convert object of type > org.postgis.PGgeometry > javax.faces.el.EvaluationException: > java.lang.IllegalArgumentException: Can't convert object of type > org.postgis.PGgeometry > at > javax.faces.component.MethodBindingMethodExpressionAdapter.invoke > (MethodBindingMethodExpressionAdapter.java:102) > at com.sun.faces.application.ActionListenerImpl.processAction > (ActionListenerImpl.java:102) > at javax.faces.component.UICommand.broadcast(UICommand.java:387) > at javax.faces.component.UIViewRoot.broadcastEvents > (UIViewRoot.java:475) > at javax.faces.component.UIViewRoot.processApplication > (UIViewRoot.java:755) > at com.sun.faces.lifecycle.InvokeApplicationPhase.execute > (InvokeApplicationPhase.java:82) > at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100) > at com.sun.faces.lifecycle.LifecycleImpl.execute > (LifecycleImpl.java:118) > at com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply > (JsfLifecycleExecutor.java:17) > at > com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.renderCycle > (ReceiveSendUpdates.java:94) > at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.service > (ReceiveSendUpdates.java:54) > at com.icesoft.faces.webapp.http.core.RequestVerifier.service > (RequestVerifier.java:26) > at > com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.ser > vice(PathDispatcherServer.java:24) > at > com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service( > MainSessionBoundServlet.java:160) > at com.icesoft.faces.webapp.http.servlet.SessionDispatcher > $1.service(SessionDispatcher.java:38) > ... > ... > > Caused by: java.lang.IllegalArgumentException: Can't convert object > of type org.postgis.PGgeometry > at org.hibernatespatial.postgis.PGGeometryUserType.convert2JTS > (PGGeometryUserType.java:123) > at org.hibernatespatial.AbstractDBGeometryType.nullSafeGet > (AbstractDBGeometryType.java:127) > at org.hibernatespatial.GeometryUserType.nullSafeGet > (GeometryUserType.java:170) > at org.hibernate.type.CustomType.nullSafeGet(CustomType.java:105) > at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81) > at > org.hibernate.persister.entity.AbstractEntityPersister.hydrate > (AbstractEntityPersister.java:2096) > at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1380) > at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java: > 1308) > at org.hibernate.loader.Loader.getRow(Loader.java:1206) > at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java: > 580) > ... > ... > > Any idea of what could be the problem? > _______________________________________________ > 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 |
||||||||||||||||
| Free Embeddable Forum Powered by Nabble | Help |