jboss 7 AS datasource for sqlserver

Marthin picture Marthin · Dec 6, 2011 · Viewed 33.2k times · Source

I run jboss in standalone mode and have set my datasource in the standalone.xml to the following:

<datasource jndi-name="MyDenaliDS" pool-name="MyDenaliDs_Pool" enabled="true" jta="true" 
                                                   use-java-context="true" use-ccm="true">
    <connection-url>
        jdbc:sqlserver://myip:1433;databaseName=mydb;integratedSecurity=true
    </connection-url>
    <driver>
        sqljdbc
    </driver>
    <security>
        <user-name>
            username
        </user-name>
        <password>
            password
        </password>
    </security>
</datasource>
<drivers>
    <driver name="sqljdbc" module="com.microsoft.sqlserver.jdbc">
        <driver-class>
            com.microsoft.sqlserver.jdbc.SQLServerDataSource
        </driver-class>
    </driver>                    
</drivers>

in the folder %jbosshome%\modules\com\microsoft\sqlserver\jdbc\ I have the sqljdb4.jar and the following module.xml:

<?xml version="1.0" encoding="UTF-8"?>
<module name="com.microsoft.sqlserver.jdbc" xmlns="urn:jboss:module:1.0">
    <resources>
        <resource-root path="sqljdbc4.jar"/> 
     </resources>
     <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/> 
     </dependencies>
</module>

When I start the jboss it gives me the following error:

> New missing/unsatisfied dependencies:    service
> jboss.jdbc-driver.sqljdbc (missing)

Anyone know what I've done incorrect or what I'm missing?

Answer

blank picture blank · Mar 15, 2012

using Jboss AS 7.1.1, as well as putting the module in %jbosshome%\modules\com\microsoft\sqlserver\jdbc\main I had to make a slight change to the xml - the driver element in standalone.xml should be :

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

and the module.xml should be:

<?xml version="1.0" encoding="UTF-8"?>

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

    <resources>
        <resource-root path="sqljdbc4.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
        <module name="javax.servlet.api" optional="true"/>
    </dependencies>

</module>