I am using Wildfly 10 and developing an application using Spatial Hibernate 5 with PostGIS database. I am getting the below error in runtime.
java.lang.IllegalStateException: Received object of type org.postgresql.util.PGobject
Can anyone suggest some good tutorials as on how to use Spatial Hibernate with Wildfly 10?
After struggling for days, I found this solution:
Don't connect to your database through a datasource defined on your wildfly. Instead, in your persistence.xml:
Because the early 5.0.x versions of hibernate apparently had no proper integration of hibernate-spatial and to avoid classpath problems, I added the file jboss-deployment-structure.xml to my META-INF:
This will prevent the wildfly provided hibernate to be used by your deployment so that you can instead add a dependency for the most recent hibernate version (5.1.0 as of this writing). You will then need to add dependencies for hibernate, hibernate-spatial and postgresql-jdbc.
Also note that hibernate 5 doesn't require the @Type annotation anymore.
I have managed to get my project working with the settings above and one of my entities featuring the following attribute / column:
I hope it helps, good luck!
Edit: Using this approach, you need to add your postgresql jdbc driver as a dependency to your project.
Edit:
I have prepared a working sample project demonstrating the use of wf10/hibernate5/postgis - check it out on github:
https://github.com/Pulvertoastmann/wf10postgis/