gpt4 book ai didi

postgresql - 创建 Wildfly 10 数据源时出现问题

转载 作者:行者123 更新时间:2023-11-29 12:57:19 31 4
gpt4 key购买 nike

我正在尝试在 Wildfly 10 中创建一个数据源以连接 PostgreSQL 9.5 数据库,我已经在 Internet 上看到了一些教程,但我仍然做不到。

如果有人能帮助我,我将不胜感激。

这是错误消息:在此处输入代码

9:06:46,300 ERROR [org.jboss.as.connector.subsystems.datasources.AbstractDataSourceService$AS7DataSourceDeployer] (MSC service thread 1-6) Error during the deployment of java:jboss/datasources/CiberWebCopierDS: javax.resource.ResourceException: IJ031103: At least one connection property must be defined for datasource-class: org.postgresql.Driver
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createConnectionFactory(LocalManagedConnectionFactory.java:108)
at org.jboss.jca.deployers.common.AbstractDsDeployer.deployDataSource(AbstractDsDeployer.java:772)
at org.jboss.jca.deployers.common.AbstractDsDeployer.createObjectsAndInjectValue(AbstractDsDeployer.java:312)
at org.jboss.as.connector.subsystems.datasources.AbstractDataSourceService$AS7DataSourceDeployer.deploy(AbstractDataSourceService.java:371)
at org.jboss.as.connector.subsystems.datasources.AbstractDataSourceService.start(AbstractDataSourceService.java:149)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

19:06:46,305 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC000001: Failed to start service org.wildfly.data-source.CiberWebCopierDS: org.jboss.msc.service.StartException in service org.wildfly.data-source.CiberWebCopierDS: WFLYJCA0033: Error during the deployment of CiberWebCopierDS
at org.jboss.as.connector.subsystems.datasources.AbstractDataSourceService.start(AbstractDataSourceService.java:163)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.jboss.msc.service.StartException in anonymous service: WFLYJCA0032: Unable to start the ds because it generated more than one cf
at org.jboss.as.connector.subsystems.datasources.AbstractDataSourceService.start(AbstractDataSourceService.java:151)
... 5 more

还有这个

19:06:47,988 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "CiberWebCopierDS")
]) - failure description: {
"WFLYCTL0080: Failed services" => {"org.wildfly.data-source.CiberWebCopierDS" => "org.jboss.msc.service.StartException in service org.wildfly.data-source.CiberWebCopierDS: WFLYJCA0033: Error during the deployment of CiberWebCopierDS
Caused by: org.jboss.msc.service.StartException in anonymous service: WFLYJCA0032: Unable to start the ds because it generated more than one cf"},
"WFLYCTL0412: Required services that are not installed:" => ["org.wildfly.data-source.CiberWebCopierDS"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined
}
19:06:47,990 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "CiberWebCopierDS")
]) - failure description: {
"WFLYCTL0080: Failed services" => {"org.wildfly.data-source.CiberWebCopierDS" => "org.jboss.msc.service.StartException in service org.wildfly.data-source.CiberWebCopierDS: WFLYJCA0033: Error during the deployment of CiberWebCopierDS
Caused by: org.jboss.msc.service.StartException in anonymous service: WFLYJCA0032: Unable to start the ds because it generated more than one cf"},
"WFLYCTL0412: Required services that are not installed:" => [
"org.wildfly.data-source.CiberWebCopierDS",
"org.wildfly.data-source.CiberWebCopierDS"
],
"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined
}
19:06:48,017 INFO [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0186: Services which failed to start: service org.wildfly.data-source.CiberWebCopierDS: org.jboss.msc.service.StartException in service org.wildfly.data-source.CiberWebCopierDS: WFLYJCA0033: Error during the deployment of CiberWebCopierDS.

这就是我创建 module.xml 的方式

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="com.h2database.h2">
<resources>
<resource-root path="h2-1.3.173.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>

这是驱动程序定义:

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

这是数据源定义:

<datasource jndi-name="java:jboss/datasources/CiberWebCopierDS" enabled="true" use-java-context="true" pool-name="CiberWebCopierDS">
<connection-rl>jdbc:postgresql://localhost:5432/CiberWebCopierDB</connection- url>
<driver>postgres</driver>
<security>
<user-name>postgres</user-name>
<password>postgresql</password>
</security>
</datasource

>

最佳答案

您提供的 module.xml 不适用于 postgres,它适用于 h2 数据库..

尝试使用以下模块,记得下载 postrgres 驱动程序,将其放在 modules/org/postgresql/main 并将“postgresql-Y.X-Z.jdbcV.jar”更改为您下载的驱动程序的名称。

你的配置的其余部分看起来不错,但我不太确定在驱动程序部分设置数据源类,我认为在数据源声明中使用驱动程序类元素。

总结:

模块.xml

 <?xml version="1.0" encoding="UTF-8"?>  
<module xmlns="urn:jboss:module:1.0" name="org.postgresql">
<resources>
<resource-root path="postgresql-Y.X-Z.jdbcV.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>

驱动定义

<driver name="postgres" module="org.postgresql"/>

数据源定义

<datasource jndi-name="java:jboss/datasources/CiberWebCopierDS" enabled="true" use-java-context="true" pool-name="CiberWebCopierDS">
<connection-url>jdbc:postgresql://localhost:5432/CiberWebCopierDB</connection-url>
<driver-class>org.postgresql.Driver</driver-class>
<driver>postgres</driver>
<security>
<user-name>postgres</user-name>
<password>postgresql</password>
</security>
</datasource>

编辑:作为旁注,我认为如果你想在驱动程序部分声明数据源类,你需要使用 xa-datasource-class 元素而不是 datasource-class,如果你愿意,你可以尝试一下。

关于postgresql - 创建 Wildfly 10 数据源时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39801384/

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