Wildfly 14 Microsoft SQL Server Configuration

8.7k Views Asked by At

I want to use MS SQL Server as a datasource in Wildfly 14, but I always get following error in the console:

ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 41) WFLYCTL0013: Operation ("add") failed - address: ([("subsystem" => "datasources"),("jdbc-driver" => "sqlserver")]) - failure description: "WFLYJCA0115: Module for driver [com.microsoft.sqlserver.jdbc] or one of it dependencies is missing: [com.microsoft.sqlserver.jdbc]"

My configuration is as follow:

standalone.xml

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

I also configured a module.xml in the following directory: wildfly-14.0.1.Final\modules\system\layers\base\com\microsoft\sqlserver\main. I also put the sqljdbc42.jar in it.

<module xmlns="urn:jboss:module:1.3" name="com.microsoft.sqlserver.jdbc">
    <resources>
        <resource-root path="sqljdbc42.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/> 
        <module name="javax.transaction.api"/> 
    </dependencies>
</module>

With Wildfly 13 and before I had no problems.

2

There are 2 best solutions below

3
On BEST ANSWER

I believe your driver configuration in the standalone.xml is still wrong.

The following have to be the same.

In standalone.xml:

<driver name="sqlserver" module="com.microsoft.sqlserver.jdbc">

In module.xml:

<module xmlns="urn:jboss:module:1.3" name="com.microsoft.sqlserver.jdbc">

Location of sqljdbc42.jar and module.xml:

JBOSS_HOME\modules\com\microsoft\sqlserver\jdbc\main\

I also believe you are using the wrong xa-datasource-class, this should be:

com.microsoft.sqlserver.jdbc.SQLServerXADataSource

Also have a look at EAP7 Documentation. It should be the same vor wildfly. There is also a good example of how to use the CLI.

2
On

add this to module.xml inside <dependencies> tag

<module name="javax.xml.bind.api"/>