3

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.

jhenrique
  • 858
  • 1
  • 10
  • 17
surfspider
  • 727
  • 3
  • 11
  • 25
  • I would suggest you to put your JDBC under _\modules\com\microsoft\sqlserver\jdbc\main\sqljdbc42.jar_ (If i'm not wrong, this is a better - if not the correct - location to your JDBCs) – jhenrique Oct 23 '18 at 14:49
  • I already put sqljdbc42.jar in the suggested folder \modules\com\microsoft\sqlserver\jdbc\main\ like module.xml. Do I have to put other files in it from the microsoft download? – surfspider Oct 23 '18 at 16:14
  • I don't think so. You need the .jar and the module.xml. Can you tell us if you also have org.h2.jdbcx.JdbcDataSource this inside the tag? – jhenrique Oct 23 '18 at 16:24
  • You also need to keep that "ExampleDS" datasource that comes in the standalone.xml. I always let it there, I just add my definitions. Keep that information, add yours and try to run again. – jhenrique Oct 23 '18 at 16:34
  • I kept the h2 driver and the "ExampleDS" datasource. This cannot be the problem. – surfspider Oct 23 '18 at 16:36
  • Which SQL Server version are you using? Are you using Java 8? If so, can you do just one more test please? Download [here](https://learn.microsoft.com/en-us/sql/connect/jdbc/download-microsoft-jdbc-driver-for-sql-server?view=sql-server-2017) JDBC Driver 7.0 or 6.4 for jre8 (mssql-jdbc-7.0.0.jre8.jar or mssql-jdbc-6.4.0.jre8.jar) and don't forget to change the name in your module.xml, copy the new .jar to your folder and start jboss again. I have the same configuration that you do, just tested here with these 2 .jars I mentioned and it's working. – jhenrique Oct 23 '18 at 16:55
  • Is there anything further up the logs? If it works in WildFly 13 it should work in WildFly 14. – James R. Perkins Nov 09 '18 at 19:24

2 Answers2

6

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.

wirnse
  • 1,026
  • 8
  • 7
  • Thank you now it works . It was a combination of 2 things and wildfly 13 was less restrictive. In Wildfly 13 the declaration of the driver class in standalone.xml worked, in wildfly 14 it has to be the datasource class. – surfspider Nov 10 '18 at 22:52
  • I too facing same issue i followed same above procedure but still the error not resolved, please let me know did you past the jar and module xml in the same folder mention above. – Nanda Jan 20 '20 at 11:49
  • Did you follow the eap7 documentation? You really should use the cli! And yes, jdbc jar and module.xml is in the same folder, as described in the answer – wirnse Jan 20 '20 at 15:17
1

add this to module.xml inside <dependencies> tag

<module name="javax.xml.bind.api"/>
Megamind
  • 11
  • 3
  • Could you clarify? What are you referring to when you say "this"? – Mathyn Jul 09 '19 at 18:05
  • I was having the same issue with missing dependencies while creating a datasource for mssql. Going over the logs it appeared like the sql jar is dependent upon the library that I have mentioned above. It worked for mssql14 and wildfly17. Hope this helps! – Megamind Jul 09 '19 at 18:11