gpt4 book ai didi

jdbc - Wildfly 10 Final postgres 驱动程序 ClassCastException

转载 作者:行者123 更新时间:2023-12-03 18:25:40 24 4
gpt4 key购买 nike

最终有人可以帮助我。目前我在启动 时遇到了一个非常奇怪的问题野蝇 10 决赛 使用 postgres 驱动程序,但设置相同 野蝇 10 CR4 将启动。

我得到的异常(exception)如下:

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。任何的想法?
对我来说,这看起来像是一个类加载器问题,但我不是 Wildfly 的专家来追踪它。

我的模块/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

非常感谢任何帮助解决我的问题。

提前谢谢

/大卫

最佳答案

实现 DataSource 的类名是:

org.postgresql.ds.PGSimpleDataSource

或者
org.postgresql.ds.PGPoolingDataSource

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

我假设 Wildfly 将管理连接,因此您可能不需要池化 DataSource,只需要简单的:
所以应该是
<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>

关于jdbc - Wildfly 10 Final postgres 驱动程序 ClassCastException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36232968/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com