Search code examples
javasql-serverjdbcjbosswindows-authentication

JBoss: Native Library sqljdbc_auth.dll already loaded in another classloader


UPDATE: This unanswered question on jboss forums, is another way of describing my exact problem: https://developer.jboss.org/thread/199888

Original post:I am trying to make integrated authentication work on web applications deployed to JBoss 7.x. I have successfully made one work, by copying sqljdbc_auth.dll into either Windows/System32, or {java location}/jre/bin. However, if two or more applications are running, I will get an error saying that Native Library sqljdbc_auth.dll already loaded in another classloader

I know why this error is happening, and this question and answer has a Tomcat solution. But I can't make it work in JBoss. Actually, putting the dll inside the jboss/bin folder gives the exact same error as before:

Failed to load the sqljdbc_auth.dll cause : 
Native Library C:\Jboss-eap-7.0\bin\sqljdbc_auth.dll already loaded in another classloader

How do I configure JBoss, and/or place the sqljdbc_auth.dll?

My deployments are not located under any module, or named server instance. I think it's simply called standalone

I have tried this approach as well, but I can not figure out where to put the jar file, in the JBoss directories. I tried deploying it as a deployment like the web applications, and I tried copying it into the lib folder, under standalone. No success.

EDIT:

I am trying to implement a global module, as per the answer posted, but get following error now:

14:00:25,333 ERROR [stderr] (ServerService Thread Pool -- 121)
java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver from 
[Module "deployment.MyWebapp.war:main" from Service Module Loader]

Solution

  • I assume you must have created a module for sql jdbc driver something like this.

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

    And added this module as dependency to each of your deployed application.

    I would suggest to declare this module as global module by editing the standalone.xml file like this ..

    <subsystem xmlns="urn:jboss:domain:ee:4.0">
                <global-modules>
                    <module name="com.microsoft.sqlserver" slot="main"/>
                     .
                     .
                </global-modules>
    .
    .
    </subsystem>
    

    And remove the dependency to this module from your individual applications.