无法在WildFly 10中安装/运行SQL Server驱动程序

时间:2016-11-29 07:28:37

标签: sql-server server wildfly wildfly-10 mssql-jdbc

我在WildFly 10服务器上运行我的应用程序。我不希望将我的连接细节放在我的应用程序src代码上,因此我试图将它放在WildFly 10服务器本身。

但是我遇到了问题。

[WILDFLY_HOME]\modules\system\layers\base\com\microsoft下, 我创建了以下目录sqlserver\main,并将我的JAR文件和我的XML文件放在主文件夹中。

我使用的JAR是sqljdbc.jar

module.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- JDBC Drivers module.xml file to configure your JDBC drivers-->

<!-- SQL Server 2014 example -->
<module xmlns="urn:jboss:module:1.3" name="com.microsoft.sqlserver">
  <resources>
    <resource-root path="sqljdbc.jar"/>
  </resources>
  <dependencies>
    <module name="javax.api"/>
    <module name="javax.transaction.api"/>
  </dependencies>
</module>

[WILDFLY_HOME]\standalone\configuration下,我修改了standalone.xml。在子系统数据源部分下,我添加了SQL Server的详细信息。

standalone.xml:

<subsystem xmlns="urn:jboss:domain:datasources:4.0">
    <datasources>
        <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
            <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
            <driver>h2</driver>
            <security>
                <user-name>sa</user-name>
                <password>sa</password>
            </security>
        </datasource>
        <datasource jndi-name="java:/TestDS" pool-name="TestDS" enabled="true" use-java-context="true">
            <connection-url>jdbc:sqlserver://localhost\test:1433;databaseName=test</connection-url>
            <driver>mssql</driver>
            <security>
                <user-name>sa</user-name>
                <password>Password123!</password>
            </security>
            <pool>
                <min-pool-size>5</min-pool-size>
                <max-pool-size>50</max-pool-size>
                <prefill>false</prefill>
                <use-strict-min>false</use-strict-min>
                <flush-strategy>FailingConnectionOnly</flush-strategy>
            </pool>
            <validation>
                <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mssql.MSSQLValidConnectionChecker"></valid-connection-checker>
            </validation>
        </datasource>
        <drivers>
            <driver name="h2" module="com.h2database.h2">
                <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
            </driver>
            <driver name="mssql" module="com.microsoft.sqlserver">
                <xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</xa-datasource-class>
            </driver>
        </drivers>
    </datasources>
</subsystem>

当我开始运行WildFly时,我现在面临的错误如下:

15:19:51,098 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("data-source" => "TestDS")
]) - failure description: {
    "WFLYCTL0412: Required services that are not installed:" => [
        "jboss.jdbc-driver.mssql",
        "jboss.jdbc-driver.mssql"
    ],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => [
        "org.wildfly.data-source.TestDS is missing [jboss.jdbc-driver.mssql]",
        "jboss.driver-demander.java:/TestDS is missing [jboss.jdbc-driver.mssql]",
        "org.wildfly.data-source.TestDS is missing [jboss.jdbc-driver.mssql]"
    ]
}
15:19:51,120 INFO  [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0184:    New missing/unsatisfied dependencies:
      service jboss.jdbc-driver.mssql (missing) dependents: [service org.wildfly.data-source.TestDS, service jboss.driver-demander.java:/TestDS]

3 个答案:

答案 0 :(得分:5)

我设法解决了这个问题。

由于我将文件放在此目录下:type Short_Array is array (Natural range <>) of Short; Items : access Short_Array; Items := new Short_Array(1..UpperBound); Items.all := (others => 0);

然后正常的模块位置应符合以下正常数据源:

[WILDFLY_HOME]\modules\system\layers\base\com\microsoft

如果您使用的是xa datasource:

<driver name="mssql" module="system.layers.base.com.microsoft.sqlserver">
    <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
</driver>

归功于@jklee

答案 1 :(得分:3)

驱动程序错误,请使用

 <driver name="mssql" module="com.microsoft.sqlserver">
    <xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class>
 </driver>

<driver name="mssql" module="com.microsoft.sqlserver">
    <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
</driver>

答案 2 :(得分:0)

您可以添加sqlserver作为全局模块,如下所示

 <subsystem xmlns="urn:jboss:domain:ee:4.0">
            <global-modules>
                <module name="com.microsoft.sqlserver" slot="main"/>
                <module name="com.sql.mysql" slot="main"/>
            </global-modules>
.
.
</subsystem>