Question

When setting the IntegratedSecurity in the XA datasource on JBoss to true, Microsoft's JDBC driver doesn't resolve the 'true' setting to boolean value but throws an error:

java.lang.NoSuchMethodException:
com.microsoft.sqlserver.jdbc.SQLServerXADataSource.setIntegratedSecurity(java.lang.String)

This is only the issue when using the XA datasource, non XA datasources work normally with integrated security.

Is there some other way to set integrated security for XA connections on JBoss, or a way to tell it to send a boolean value when setting the xa-datasource-property?


To reproduce this behavior:

a) In the JBoss AS configuration\standalone\standalone.xml add a new xa-datasource to JNDI:

<xa-datasource jta="true" jndi-name="java:jboss/datasources/jndiName" pool-name="poolName" enabled="true" use-java-context="true" use-ccm="true">
    <xa-datasource-property name="ServerName">
        localhost
    </xa-datasource-property>
    <xa-datasource-property name="DatabaseName">
        MyDbName
    </xa-datasource-property>
    <xa-datasource-property name="SelectMethod">
        cursor
    </xa-datasource-property>
    <!-- this should work but doesn't -->
    <xa-datasource-property name="IntegratedSecurity">
        true
    </xa-datasource-property>
    <xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class>
    <driver>sqljdbc</driver>
    <xa-pool>
        <is-same-rm-override>false</is-same-rm-override>
    </xa-pool>
    <validation>
        <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mssql.MSSQLValidConnectionChecker"/>
    </validation>
</xa-datasource>

b) Restart JBoss AS

c) Try to execute a query using the configured JNDI connection:

InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup("java:jboss/datasources/jndiName");
Connection conn = null;
try {
    conn = ds.getConnection();

    // try to execute something
    CallableStatement stmt = conn.prepareCall("{? = call some_stored_procedure()}");
    stmt.execute();
} finally {
    if (conn != null)
        conn.close();
}

Executing this code will result in an exception stating:

java.lang.NoSuchMethodException: 
com.microsoft.sqlserver.jdbc.SQLServerXADataSource.setIntegratedSecurity(java.lang.String)
Was it helpful?

Solution

I've also run into this, but I was able to get this to work if I use the URL xa-datasource-property.

Example:

<xa-datasource-property name="URL">jdbc:sqlserver://<host>:<port>;database=<db>;integratedSecurity=true</xa-datasource-property>  

These snippets would need to be removed:

<xa-datasource-property name="ServerName">
    localhost
</xa-datasource-property>
<xa-datasource-property name="DatabaseName">
    MyDbName
</xa-datasource-property>
<xa-datasource-property name="SelectMethod">
    cursor
</xa-datasource-property>
<!-- this should work but doesn't -->
<xa-datasource-property name="IntegratedSecurity">
    true
</xa-datasource-property>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top