Native Library sqljdbc_auth.dll already loaded in another classloader

前端 未结 3 954
忘了有多久
忘了有多久 2020-11-28 10:58

I have 2 java web apps that need to connect to SQL Server Database using Windows Integrated Authentication.

The first one that is loaded works fine but the second on

3条回答
  •  情深已故
    2020-11-28 11:13

    Each web application has its own Classloader (isolating them). When you call the Class.forName() method, there is a static block which is trying to load the shared library (dll file) - so both your web apps are trying to load the shared lib, hence the error message when the second one attempts to load.

    The JDBC jar you have for sqlserver should be moved from being bundled with your wars, to the tomcat 7.0/lib folder and copy the sqljdbc_auth.dll to tomcat/bin folder - this way it will be in the tomcat parent classloader, and the class will only be loaded once.

    |----------------------------------|
    | sqljdbc*.jar     --> tomcat*/lib |
    |----------------------------------|
    | sqljdbc_auth.dll --> tomcat*/bin |
    |----------------------------------|
    

提交回复
热议问题