2

I have big issues using sqljdbc4.jar in Wildfly 10. When I start the server I get the following issue:

Unable to instantiate driver class "com.microsoft.sqlserver.jdbc.SQLServerDataSource" 

... and several exceptions ...

08:32:12,570 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC000001: Failed to start service jboss.deployment.subunit."PPJAS.ear"."WebService.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.subunit."PPJAS.ear"."WebService.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of subdeployment "WebService.war" of deployment "PPJAS.ear"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:154)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)

What I did till now:

Creating a Folder for the .jar with the .jar itsself and the module.xml:

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

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

.. at C:\Program Files\Wildfly\wildfly-10.0.0.Final\modules\com\microsoft\sqlserver\main

Added the datasource and the driver in the standalone.xml

<datasource jndi-name="java:jboss/datasources/DBName" pool-name="DBPoolName">
                    <connection-url>jdbc:microsoft:sqlserver://IP:Port;DatabaseName=DBName</connection-url>
                    <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDataSource</driver-class>
                    <driver>sqlserver</driver>
                    <security>
                        <user-name>username</user-name>
                        <password>password</password>
                    </security>
                    <validation>
                        <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mssql.MSSQLValidConnectionChecker"/>
                    </validation>
                </datasource>

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

I (might??) did the same procedure with the MySQL Driver without any problems. I also tried to add the datasource via the web interface wildfly management but the system also cannot find the specific driver.

Does anyone have any ideas?

Thanks for your time!

Starburst
  • 33
  • 1
  • 6
  • Try removing the `` from the data source definition. – James R. Perkins Jan 25 '17 at 21:27
  • Same Error, seems that the failure is related to the driver definition section. I also have set the entry for other datasources like MySQL-Databases without any issues - If this info might help. – Starburst Jan 26 '17 at 07:50
  • Is there a stack trace from the first error? – James R. Perkins Jan 26 '17 at 16:30
  • I fixed it. First Problem was the naming of the driver class. It hast to be jdbc.SQLServerDriver and not jdbc.SQLServerDataSource. After that I had some problems that wildfly said that it couldn't find the persistence unit which was just because of case sensitive stuff (ensure that you use everywhere the same name with the right letter case). Thanks for your time. If I found time i will update my post with the correct xml to show other users how to handle this... – Starburst Jan 27 '17 at 06:19

1 Answers1

0

I had the same problem and the correct configuration is: standalone.xml

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

module.xml

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

Software tested: JbossEAP 7.2 JDK version: 8 SQL Server JDBC Driver version: mssql-jdbc-6.2.2.jre8.jar

Portion of the log:

14:02:49,587 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 41) WFLYJCA0004: Deploying JDBC-compliant driver class com.microsoft.sqlserver.jdbc.SQLServerDriver (version 6.2) 14:02:49,589 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-5) WFLYJCA0018: Started Driver service with driver-name = sqlserver

Regards.

aduenas
  • 1
  • 1