如何在WildFly 16中配置Redshift XADatasource

时间:2019-06-20 20:05:53

标签: java-ee wildfly amazon-redshift

我正在将Spring Enterprise Java应用程序从Tomcat 6迁移到Wildfly 16,但是我无法配置Amazon Redshift连接数据源。我收到此消息:

ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 42) WFLYCTL0013: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("jdbc-driver" => "redshift")
]) - failure description: "WFLYJCA0114: Failed to load datasource class: com.amazon.redshift.jdbc42.DataSource"

此外,在部署结束时,我收到以下消息:

ERROR org.jboss.as.controller.management-operation  - WFLYCTL0013: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("xa-data-source" => "jdbc/redshift")
]) - failure description: {
    "WFLYCTL0412: Required services that are not installed:" => [
        "jboss.jdbc-driver.redshift",
        "jboss.jdbc-driver.redshift"
    ],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => [
        "jboss.driver-demander.java:jboss/resources/jdbc/redshift is missing [jboss.jdbc-driver.redshift]",
        "org.wildfly.data-source.jdbc/redshift is missing [jboss.jdbc-driver.redshift]",
        "org.wildfly.data-source.jdbc/redshift is missing [jboss.jdbc-driver.redshift]"
    ]
}

我的standalone.xml配置是这样的:

<xa-datasource jndi-name="java:jboss/resources/jdbc/myJndi" pool-name="jdbc/myJndi">
  <xa-datasource-property name="ServerName">
    SomeIp
  </xa-datasource-property>
  <xa-datasource-property name="PortNumber">
    1634
  </xa-datasource-property>
  <xa-datasource-property name="DatabaseName">
    myDatabase
  </xa-datasource-property>
  <driver>redshift</driver>
  <security>
    <user-name>user</user-name>
    <password>password</password>
  </security>
</xa-datasource>

在独立的驱动程序部分中,我也这样:

<driver name="redshift" module="com.amazon.redshift">
  <xa-datasource-class>com.amazon.redshift.jdbc42.DataSource</xa-datasource-class>
</driver>

如果我使用<datasource>标签和<connection-url>配置此数据源,则不会显示该错误,但是我将无法使用事务。

注意:我发现Amazon Redshift基于Postgresql,因此我尝试使用相同的参数但通过使用postgresql驱动程序来配置此XADataSource,它显然运行良好(我使用XA Datasource Class org.postgresql.xa.PGXADataSource )。我想知道是否有一种方法可以解决此redshift问题而无需这样做(使用postgresql驱动程序)。我的配置有问题吗?我应该使用哪个XADatasource类进行redshift?

1 个答案:

答案 0 :(得分:0)

看起来您在独立驱动程序部分中引用了jdbc驱动程序,但错误表明未安装该驱动程序。您可以下载与jdbc 4.2兼容的驱动程序here