空间休眠5在野蛮10 [英] Spatial Hibernate 5 On Wildfly 10

查看:107
本文介绍了空间休眠5在野蛮10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Wildfly 10并开发了一个使用Spatial Hibernate 5和PostGIS数据库的应用程序。

  java.lang.IllegalStateException:接收到的类型为org.postgresql.util.PGobject的对象

任何人都可以推荐一些关于如何在Wildfly 10中使用Spatial Hibernate的教程?

解决方案

我有同样的问题,我只是修复它。这基本上是一个依赖性问题。问题在于你在你的wildfly模块和部署WEB-INF / lib上加载postgresql和/或postgis jar。
我通过standalone.xml上的常规DS连接到我的数据库

 < datasource jndi-name = java:jboss / datasources / mygisDSpool-name =mygisDSuse-java-context =true> 
< connection-url> jdbc:postgresql:// localhost:5432 / keycloak< / connection-url>
< driver> org.postgresql< / driver>
< transaction-isolation> TRANSACTION_READ_COMMITTED< / transaction-isolation>
< pool>
< min-pool-size> 10< / min-pool-size>
< max-pool-size> 100< / max-pool-size>
< prefill> true< / prefill>
< use-strict-min> false< / use-strict-min>
< flush-strategy> FailingConnectionOnly< / flush-strategy>
< / pool>
< security>
<用户名>用户< /用户名>
<密码> XXXXXX< /密码>
< / security>
< / datasource>

我的司机

 < driver name =org.postgresqlmodule =org.postgresql> 
< xa-datasource-class> org.postgresql.xa.PGXADataSource< / xa-datasource-class>
< / driver>

我试过@Toastor说,它可能解决了他的问题,但它并不适用于我。尽管他给了我一些线索。因此,大部分关于互联网的文档已经过时了,并且hibernate空间上没有太多的东西。5.我添加了postgis-jdbc到我的maven到我野蛮人内部的postgresql的module.xml中,但是我正在阅读Hibernate Spatial 5.X中的这不是必需的。 Wildfly 10默认使用5.0.7,我使用的是hibernate 5.1.0.Final,因此我没有将我的pom.xml中的任何hibernate组件的作用域设置为提供。
但是一切都不成功。所以我追溯了我的图书馆。

  mvn依赖关系:树

您必须检查被调用的任何postgresql库或任何postgis库。我发现Hibernate Spatial 5.1有一些postgresql依赖关系,所以我将它们排除在hibernate空间之外。

 < exclusion> 
< artifactId> postgresql< / artifactId>
< groupId> org.postgresql< / groupId>
< /排除>

我这样做,并且发现PGobject有问题,它说没有找到类。所以我将它添加到jboss-deployment-structure.xml中。

 <?xml version =1.0encoding =UTF- 8\" >?; 
< jboss-deployment-structure>
< deployment>
<依赖关系>
< module name =org.postgresql/>
< /依赖关系>
< / deployment>
< / jboss-deployment-structure>

而且这样做的工作。如果您有类似的问题,请使用maven dependency:tree来跟踪您的库。


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?

解决方案

I had the same problem and I just fixed it. It is basically a dependency issue. The problem is that you are loading the postgresql and/or postgis jars on your wildfly modules and on you deployments WEB-INF/lib. I connect to my database with a regular DS on my standalone.xml

<datasource jndi-name="java:jboss/datasources/mygisDS" pool-name="mygisDS" use-java-context="true">
                    <connection-url>jdbc:postgresql://localhost:5432/keycloak</connection-url>
                    <driver>org.postgresql</driver>
                    <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
                    <pool>
                        <min-pool-size>10</min-pool-size>
                        <max-pool-size>100</max-pool-size>
                        <prefill>true</prefill>
                        <use-strict-min>false</use-strict-min>
                        <flush-strategy>FailingConnectionOnly</flush-strategy>
                    </pool>
                    <security>
                        <user-name>user</user-name>
                        <password>XXXXXX</password>
                    </security>
                </datasource>

My drivers

<driver name="org.postgresql" module="org.postgresql">
                        <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
                    </driver>

I tried as @Toastor said, it might have solve his issues but it didnt work with me. Although he gave me a few clues.

So most documentation around the internet is outdated, and there is not much on hibernate spatial 5. I added postgis-jdbc to my maven to my postgresql's module.xml inside my wildfly, but as I was reading THIS IS NOT NECESSARY in Hibernate Spatial 5.X. Wildfly 10 uses 5.0.7 by default, I was using hibernate 5.1.0.Final, so I did not set the scope of any hibernate component on my pom.xml as "provided". But everything kept failing too. So I traced my libraries.

mvn dependency:tree

You have to check for any postgresql libraries that are called or any postgis libraries. What I found out is that Hibernate Spatial 5.1 has some postgresql dependencies, so I excluded them from hibernate spatial.

        <exclusion>
            <artifactId>postgresql</artifactId>
            <groupId>org.postgresql</groupId>
        </exclusion>

I did this and I found a problem with PGobject, it said something like class not found. So I added it to jboss-deployment-structure.xml

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <deployment>
        <dependencies>
            <module name="org.postgresql" />
        </dependencies>
    </deployment>
</jboss-deployment-structure>

And this did the work. If you have a similar problem use maven dependency:tree to trace your libraries.

这篇关于空间休眠5在野蛮10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆