arj*_*soh 4 postgresql datasource java-ee wildfly
我试图在Mac OS上的Wildfly 10 Application Server中配置PostgreSQL数据源.我正在按照说明书的规定行事.我创建了一个订单:
/wildfly-10.1.0.Final/modules/system/layers/base/org/postgresql/main.
Run Code Online (Sandbox Code Playgroud)
按此顺序我放了JDBC驱动程序:
postgresql-9.3-1104.jdbc4.jar
Run Code Online (Sandbox Code Playgroud)
我创建了一个module.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="org.postgresql“>
<resources>
<resource-root path="postgresql-9.3-1104.jdbc4.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Run Code Online (Sandbox Code Playgroud)
在standalone.xml文件中,我在datasources下创建了数据源:
<datasource jndi-name="java:jboss/datasources/PostgresDS" pool-name="PostgresDS" enabled="true"
use-java-context="true">
<connection-url>jdbc:postgresql://localhost:5432/testdb</connection-url>
<driver>postgresql</driver>
<security>
<user-name>user</user-name>
<password>password</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker"></valid-connection-checker>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter"></exception-sorter>
</validation>
</datasource>
Run Code Online (Sandbox Code Playgroud)
和司机:
<drivers>
<driver name="postgresql" module="org.postgresql">
<datasource-class>org.postgresql.Driver</datasource-class>
<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
</driver>
</drivers>
Run Code Online (Sandbox Code Playgroud)
但是,不能安装数据源,当我启动服务器时,我收到消息(错误):
ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "PostgresDS")
]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.postgresql"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"org.wildfly.data-source.PostgresDS is missing [jboss.jdbc-driver.postgresql]",
"jboss.driver-demander.java:jboss/datasources/PostgresDS is missing [jboss.jdbc-driver.postgresql]"
]
}
[org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "PostgresDS")
]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => [
"jboss.jdbc-driver.postgresql",
"jboss.jdbc-driver.postgresql"
],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"org.wildfly.data-source.PostgresDS is missing [jboss.jdbc-driver.postgresql]",
"jboss.driver-demander.java:jboss/datasources/PostgresDS is missing [jboss.jdbc-driver.postgresql]",
"org.wildfly.data-source.PostgresDS is missing [jboss.jdbc-driver.postgresql]"
]
}
Run Code Online (Sandbox Code Playgroud)
看来,wildfly也许找不到模块.是什么原因导致了这个问题?我的配置有什么问题吗?
我想建议您更改流程.虽然您当然可以手动执行此操作,但如果您编写此脚本,则可以使用可重复性再次执行此操作.
这取决于jboss-cli.sh.我有一个看起来像这样的脚本:
embed-server --std-out=echo --server-config=standalone.xml
batch
module add --name=org.postgres --resources=/tmp/postgresql-42.0.0.jar --dependencies=javax.api,javax.transaction.api
/subsystem=datasources/jdbc-driver=postgres:add(driver-name="postgres",driver-module-name="org.postgres",driver-class-name=org.postgresql.Driver)
/subsystem=datasources/data-source=myDataSource/:add(connection-url=jdbc:postgresql://localhost:5432/thedatabasename,driver-name=postgres,jndi-name=java:/jdbc/myDataSource,initial-pool-size=4,max-pool-size=64,min-pool-size=4,password=theDatabasePassword,user-name=theDatabaseUsername)
run-batch
Run Code Online (Sandbox Code Playgroud)
这是运行:
bin/jboss-cli.sh --file=/path/to/file/wildflyconf.cli
Run Code Online (Sandbox Code Playgroud)
该脚本首先使用"embed-server"命令启动,以便您的Wildfly实例不需要运行.然后它启动一批命令作为一个单元运行.
重要的是我们通过命令行创建模块.您必须将PostgreSQL jar放在某处,但除此之外,脚本负责在"modules"下创建所有需要的文件.
接下来,我们添加JDBC驱动程序,然后基于驱动程序创建数据源.
脚本的优点是您可以将其检入源代码控制系统,任何人都可以运行它.它减少了拼写错误的可能性,您无需手动创建和修改文件.
只是一个想法.拥有可重复的流程,您的开发团队可以使用它始终是一件有用的事情.
| 归档时间: |
|
| 查看次数: |
10462 次 |
| 最近记录: |