Wildfly 10 Final postgres驱动程序ClassCastException [英] Wildfly 10 Final postgres driver ClassCastException

查看:130
本文介绍了Wildfly 10 Final postgres驱动程序ClassCastException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最终有人可以帮助我。目前,当我使用postgres驱动程序启动 wildfly 10 Final 但使用相同的设置 wildfly 10 CR4 时,我会遇到一个非常奇怪的问题。

eventually somebody can help me. Currently I have a really strange problem when starting wildfly 10 Final with a postgres driver but with the same setting wildfly 10 CR4 will start up.

我得到的异常如下:

Caused by: javax.resource.ResourceException: IJ031089: Failed to load datasource: org.postgresql.Driver
    at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getDataSource(LocalManagedConnectionFactory.java:650)
    at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:311)
    ... 6 more
Caused by: java.lang.ClassCastException: org.postgresql.Driver cannot be cast to javax.sql.DataSource
    at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getDataSource(LocalManagedConnectionFactory.java:633)
    ... 7 more

奇怪的是,它可以在wildfly 10上运行CR4,但不在最终版本的wildfly 10 Final上。任何的想法?
对我来说,这看起来像是一个类加载器问题,但我并不是怀有野性的专家来跟踪它。

The strange thing is, it works on wildfly 10 CR4 but not on the final version wildfly 10 Final. Any Idea? For me it looks like a class loader problem but I'm not that an expert with wildfly to track it down.

我的 modules / org /postgres/main/module.xml

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.postgres">
  <resources>
    <resource-root path="postgresql-9.4.1208.jar"/>
  </resources>
  <dependencies>
    <module name="javax.api"/>
    <module name="javax.transaction.api"/>
    <module name="javax.servlet.api" optional="true"/>
  </dependencies>
</module>

我在 standalone.xml

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

Java JDK是:jdk1.8.0_73

Java JDK is: jdk1.8.0_73

非常感谢您能解决我的问题。

Would really appreciate any help to fix my problem.

预先感谢

/大卫

推荐答案

实现数据源的类名称为:

The class name implementing a DataSource is either:

org.postgresql.ds.PGSimpleDataSource

org.postgresql.ds.PGPoolingDataSource

https://jdbc.postgresql.org/documentation/head/ds-ds .html

我假设Wildfly将管理连接,因此您可能不需要池化DataSource,只需简单的
就可以了应该是

I assume Wildfly will manage the connections, so you probably don't need the pooling DataSource, only the simple: So it should be

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

这篇关于Wildfly 10 Final postgres驱动程序ClassCastException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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