我的 thorntail/swarm 应用程序需要 2 个 xa 数据源,但我不明白在哪里放置相关信息。从我读到的内容看来,我需要一个 project-default.yml 文件,例如:
swarm:
datasources:
xa-data-sources:
statsDS:
driver-name: postgresql
connection-url: jdbc:postgresql://postgres:5432/stats
user-name: stats
password: stats++
OracleDS:
driver-name: oracle
connection-url: jdbc:oracle:thin:@oracle:1521:XE
user-name: ora
password: ora++
jdbc-drivers:
oracle:
driver-class-name: oracle.jdbc.OracleDriver
xa-datasource-class: oracle.jdbc.xa.client.OracleXADataSource
driver-module-name: com.oracle
postgresql:
driver-class-name: org.postgresql.Driver
xa-datasource-class: org.postgresql.xa.PGXADataSource
driver-module-name: org.postgresql
还有一些 *-ds.xml 文件,在这些 *-ds.xml 文件中,我发现一些与 project-default.yml 相同的信息。例如, oracle-ds.xml :
<?xml version="1.0" encoding="UTF-8"?>
<datasources xmlns="http://www.jboss.org/ironjacamar/schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">
<!-- The datasource is bound into JNDI at this location. We reference this
in META-INF/persistence.xml -->
<xa-datasource
jndi-name="java:jboss/datasources/oracleDS" pool-name="oracle">
<xa-datasource-property name="URL">
jdbc:oracle:thin:@oracle:1521:XE
</xa-datasource-property>
<driver>oracle</driver>
<security>
<user-name>ora</user-name>
<password>ora++</password>
</security>
<validation>
<valid-connection-checker
class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker" />
<stale-connection-checker
class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker" />
<exception-sorter
class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter" />
</validation>
</xa-datasource>
</datasources>
为什么这两个文件中的信息(驱动程序、用户、密码、url)相同?
无论如何,这个conf不起作用:
2018-09-30 14:07:19,377 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 6) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("xa-data-source" => "statsDS")
]) - failure description: "WFLYCTL0155: 'jndi-name' may not be null"
只是为了完成 postgresql-ds.xml :
<?xml version="1.0" encoding="UTF-8"?>
<datasources xmlns="http://www.jboss.org/ironjacamar/schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">
<xa-datasource jndi-name="java:jboss/datasources/statsDS"
pool-name="PostgresXADS">
<xa-datasource-property name="URL">
jdbc:postgresql://postgres:5432/stats
</xa-datasource-property>
<driver>postgresql</driver>
<security>
<user-name>stats</user-name>
<password>stats++</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>
</xa-datasource>
</datasources>
如果我不使用 project-default.yml,而只使用 *-ds.xml 文件,我有:
"WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.oracle"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.data-source.\"jboss.naming.context.java.jboss.datasources.oracleDS\" is missing [jboss.jdbc-driver.oracle]"]
我可能会准确地说我的资源/模块/com/oracle/main 目录中有一个 module.xml 和 ojdbcxxx.jar。
那么我应该如何让我的 2 个 XA 数据源在我的项目中工作呢?谢谢 ...