Tuesday, June 20, 2006

Solution for Java error "native library c:\test.dll already loaded in another classloader while loading driver MyDriver"

"java.lang.UnsatisfiedLinkError: Native Library C:\test.dll already loaded in another classloader" can happen in Lotus Notes/Domino when Java agents or libraries use native calls to Windows DLL files.
What was strange about this error is that the same Java scriptlibrary worked fine in Java agent, but not in LS2J LotusScript agent.

I guess the error happens because the JAR file (the one which calls the DLL) is automatically detached at run-time and gets a new filename each time, which confuses JVM. With pure Java agents this behaviour might be different and the error does not occur.

Anyway, here is the solution:
Instead of including JAR files directly into the Java agent/scriptlibrary, put them into Notes's classpath.

3 comments:

Christian Mueller said...

I've had simula problems. The reason is, that the first time the dll will be loaded by an agent and after that, the dll won't be released. The solution is, that you load the DLL on Startup of the Lotus Notes client:

The parameter in the notes.ini should be:
JavaUserClasses=...;<yourFile.jar>

Andrei Kouvchinnikov said...

Hello Christian. Thanks for suggestion with JavaUserClasses. I copied the JAR file to the default directory of Notes Java libraries: (C:\notes\)jvm\lib\ext. The error occured in my case only when Java code was called from LS2J LotusScript, not in pure Java agent. Once error happened from LS2J, pure Java agent also stopped to work until Notes restart.

Adi said...

Oes Tsetnoc one of the ways in which we can learn seo besides Mengembalikan Jati Diri Bangsa. By participating in the Oes Tsetnoc or Mengembalikan Jati Diri Bangsa we can improve our seo skills. To find more information about Oest Tsetnoc please visit my Oes Tsetnoc pages. And to find more information about Mengembalikan Jati Diri Bangsa please visit my Mengembalikan Jati Diri Bangsa pages. Thank you So much.
Oes Tsetnoc | Semangat Mengembalikan Jati Diri Bangsa