Received object of type org.postgresql.util.PGobject

只愿长相守 提交于 2019-12-01 09:01:31

You need to add Postgis, hibernate-spatial and the other related libs to your Wildfly before deploying your application, this is because the hibernate that you are using is the bundled with the wildfly but the other libraries are bundled with your war, so they are using different classloaders.

If you check this code you can see that the cast is correct, and the error message make no sense, this is tipically a issue with classloaders.

To fix this issue you need to add all libs to your wildfly, to do this you 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 the module.xml file to add your 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 the dependencies tag, add:

<module name="org.slf4j"/>

Also if you are using postgresql, you need to add in the dependencies tag:

<module name="org.postgresql"/>

Use the correct version in the mvn command to download the correct jar.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!