top of page
opovidooseg

Dll Already Loaded In Another Classloader Tomcat: What It Means and How to Fix It



net.sf.jasperreports.engine.JRException: com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication. ClientConnectionId:9283132b-3022-4a9a-8ae4-8c869f84a6b5at net.sf.jasperreports.data.jdbc.JdbcDataAdapterService.contributeParameters(JdbcDataAdapterService.java:130)at net.sf.jasperreports.data.AbstractDataAdapterService.test(AbstractDataAdapterService.java:129)at com.jaspersoft.studio.data.wizard.AbstractDataAdapterWizard$3.run(AbstractDataAdapterWizard.java:163)at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication. ClientConnectionId:9283132b-3022-4a9a-8ae4-8c869f84a6b5at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1667)at com.microsoft.sqlserver.jdbc.AuthenticationJNI.(AuthenticationJNI.java:60)at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:2229)at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:41)at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:2220)at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1326)at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)at net.sf.jasperreports.data.jdbc.JdbcDataAdapterService.getConnection(JdbcDataAdapterService.java:168)at net.sf.jasperreports.data.jdbc.JdbcDataAdapterService.contributeParameters(JdbcDataAdapterService.java:128)... 3 moreCaused by: java.lang.UnsatisfiedLinkError: Native Library [...]\sqljdbc_auth.dll already loaded in another classloaderat java.lang.ClassLoader.loadLibrary1(Unknown Source)at java.lang.ClassLoader.loadLibrary0(Unknown Source)at java.lang.ClassLoader.loadLibrary(Unknown Source)at java.lang.Runtime.loadLibrary0(Unknown Source)at java.lang.System.loadLibrary(Unknown Source)at com.microsoft.sqlserver.jdbc.AuthenticationJNI.(AuthenticationJNI.java:35)... 14 more




Dll Already Loaded In Another Classloader Tomcat



Upon further research, the java.lang.UnsatisfiedLinkError: Native Library [...]\sqljdbc_auth.dll already loaded in another classloader, is caused when Java is attempting to load a native library after already loading it once.


The problem got resolved after the Command 2 got executed leading to another situation wherein I am able to access the SQL Server Camunda Database successfully but unable to use the sqljdbc_auth dll for my Custom Application database with the error - Native Library sqljdbc_auth.dll already loaded in another classloader.I have added the sqljdbc jar to the $TOMCAT_HOME lib folder and the DLL extension to the $TOMCAT_HOME bin folder and I am using the Camunda Tomcat Distribution for my Custom Application as well.


My use case being:I have a Camunda Application and a separate Custom Application which calls the process engine and initiates or executes BPMN related tasks using Rest API calls. Initially I continued using the inbuilt h2 database for Camunda and Sql Server database for Custom application and everything worked fine. But now I need to switch to Sql Server database for Camunda as well. And as described in the docs, when I do so I am able to successfully create a connection and use it for Camunda. But the problem arises when I also need to login to my Custom application and I am unable to do so because the sqljdbc_auth.dll(used for integrated authentication) is already in use as per the database configurations specified in thetomcat->conf->server.xml file.


got some more info this time... here's the new log entry:19-May-2009 08:37:38 hudson.util.ProcessTreeKiller getWARNING: Failed to load winp. Reverting to the defaultjava.lang.UnsatisfiedLinkError: Native Library C:\Program Files\Apache SoftwareFoundation\Tomcat 6.0\webapps\hudson\WEB-INF\lib\winp.dll already loaded inanother classloaderat java.lang.ClassLoader.loadLibrary0(Unknown Source)at java.lang.ClassLoader.loadLibrary(Unknown Source)at java.lang.Runtime.load0(Unknown Source)at java.lang.System.load(Unknown Source)at org.jvnet.winp.Native.loadDll(Native.java:135)at org.jvnet.winp.Native.load(Native.java:87)at org.jvnet.winp.Native.(Native.java:50)at org.jvnet.winp.WinProcess.enableDebugPrivilege(WinProcess.java:195)at hudson.util.ProcessTreeKiller$Windows.(ProcessTreeKiller.java:211)at hudson.util.ProcessTreeKiller.get(ProcessTreeKiller.java:131)at hudson.Launcher$LocalLauncher.kill(Launcher.java:439)at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:277)at hudson.model.Run.run(Run.java:927)at hudson.model.Build.run(Build.java:112)at hudson.model.ResourceController.execute(ResourceController.java:93)at hudson.model.Executor.run(Executor.java:119)


java.lang.UnsatisfiedLinkError: Native Library C:\WINDOWS\system32\jacob.dll already loaded in another classloader java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1716) java.lang.ClassLoader.loadLibrary(ClassLoader.java:1676) java.lang.Runtime.loadLibrary0(Runtime.java:822) java.lang.System.loadLibrary(System.java:993) com.jacob.com.LibraryLoader.loadJacobLibrary(LibraryLoader.java:57) com.jacob.com.JacobObject.(JacobObject.java:150) com.bib.customimage.JacobScript.doPost(JacobScript.java:56) javax.servlet.http.HttpServlet.service(HttpServlet.java:709) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


I'm not sure how we'd work around that. If the dll is accessible, then we could just log the fact that the DLL was already loaded. Either way, someone would have to write a test program that demonstrates the problem so that a fix could be coded.


Each service was loaded in a separate classloader without using the shared classes jointly. All common classes, about 90% of them, were loaded up to 20 times. The result was a PermGen out-of-memory error 45 minutes after startup.


I was able to identify this by getting a histogram memory dump from the JVM in question (jmap -histo). If a class is loaded multiple times, its instances are also counted multiple times. If we see a single class several times with different counters, we know that it was loaded multiple times. I subsequently requested a full heap dump and analyzed the references to the classes that were loaded multiple times. I found that the same JAR file was loaded via different classloaders!


Especially in application servers and OSGi containers, there is another form of memory leak: the classloader leak. As classes are referenced by their classloaders, they get removed when the classloader is garbage-collected. That will happen only when the application gets unloaded. Consequently, there are two general forms of classloader leak:


A classloader will be removed by the garbage collector only if nothing else refers to it. All classes hold a reference to their classloader and all objects hold references to their classes. As a result, if an application gets unloaded but one of its objects is still being held (e.g., by a cache or a thread-local variable), the underlying classloader cannot not be removed by the garbage collector!


You cannot share sessions directly across web apps, as that would be a violation of the Servlet Specification. There are workarounds, including using a singleton class loaded from the common classloader repository to hold shared information, or putting some of this shared information in a database or another data store. Some of these approaches have been discussed on the tomcat-user mailing list, whose archives you should search for more information.


When you create a custom subclass of RealmBase or GenericPrincipal and attempt to use those classes in your webapp code, you'll probably have problems with ClassCastException. This is because the instance returned by request.getUserPrincipal() is of a class loaded by the server's classloader, and you are trying to access it through you webapp's classloader. While the classes maybe otherwise exactly the same, different (sibling) classloaders makes them different classes.


The important thing to know about using JNI under Tomcat is that one cannot place the native libraries OR their JNI interfaces under the WEB-INF/lib or WEB-INF/classes directories of a web application and expect to be able to reload the webapp without restarting the server. The class that calls System.loadLibrary(String) must be loaded by a classloader that is not affected by reloading the web application itself.


Implementing Java class reloading is not the easiest thing in the world. But if you give it a shot, and at some point find your classes being loaded on the fly, then you are almost there already. There will be very little left to do before you can achieve totally superb clean design for your system.


java.lang.UnsatisfiedLinkError: no ST3J in java.library.path at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.loadLibrary0(Unknown Source) at java.lang.System.loadLibrary(Unknown Source) at client.ST3.(ST3.java:151) at client.EncryptDecrypt.(EncryptDecrypt.java:49) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at java.lang.Class.newInstance0(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:119) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1073) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:824) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:403) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:301) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:162) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)Please help me!I already check java path. 2ff7e9595c


0 views0 comments

Recent Posts

See All

Comments


bottom of page