JDK-4748750 : UnsatisfiedLinkError exception throws when load native DLL second time via jni
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 1.4.1
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2002-09-17
  • Updated: 2002-09-17
  • Resolved: 2002-09-17
Related Reports
Duplicate :  
Description
###@###.### 2002-09-17

J2SE Version (please include all output from java -version flag):
 java version "1.4.1-rc"
 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-rc-b19)
 Java HotSpot(TM) Client VM (build 1.4.1-rc-b19, mixed mode)

Operating System Configuration Information (be specific):
 Win2K

Bug Description:
 Having a problem with an applet that loads a native dll second time via
 jni. The first time the applet's init() method is called the dll is loaded as
 expected and the applet is operational. Then the page that hosts the applet 
 is unloaded and the applet is destroyed (that is, the applet's destroy() method
 is called). At this point we would expect to be able to load the applet again
 from another site. However, when we try to do this the VM throws the
 following exception:

   "c:\TEMP\\EtJniCapiLibrary.dll" java.lang.UnsatisfiedLinkError: Native
   Library C:\temp\\EtJniCapiLibrary.dll already loaded in another classloader

Impact Statememt: 
  With this problem, not be able to support CAPI applet and support Microsoft
  Digital IDS/ Smart Card support , when end users are using Sun Plugin as their
  JVM. Customer would really like to add this support, otherwise today they will
  be resrticted to supporting this only when using IE with MS JVM , and not
  solution in Windows XP as IE does not have a JVM and MS has pulled the JVM
  dowload from their site.

Steps to Reproduce (be specific):

  1) Edit the hosts file (c:\winnt\system32\drivers\etc\hosts) to include the
     following entry:

 	216.191.252.73	libloadertest.entrust.com 

     Basically by doing this from the machine on which you make the above
     modification , you are making libloadertest.entrust.com go to the same site
     as entinterop.entust.com.  but to the browser and the JVM it would seem
     like a different site / code base from which it is downloading the applet.

2) Open the browser and go to

     https://entinterop.entrust.com/TruePassSample/AuthenticateUserCapi.html.

   This is the page that downloads the CAPI applet to allow users to do login
   using a certificate in Microsoft CAPI store.

3) You will get a "No CAPI profiles" error message because no CAPI profiles 
   got issued to work with, but this error message is a valid one and indicates
   the applet got intialized and loaded fine and trying to find a CAPI profile
   to use to authenticate to the site.

4) Keep the browser open and go to
   https://libloadertest.entrust.com/TruePassSample/AuthenticateUserCapi.html.

   (go to antoher site in the same browser session and download the same CAPI
    applet jar file)

5) You will see a different error message at Java Console where it fails to 
   load the EtJniCAPIlibrary.dll when go to the second site in the same
   browser session, from where the CAPI applet gets downloaded:

   EntrustTruePassApplet/6.0] [EMERGENCY] Could not load CAPI DLL at
   "C:\TEMP\TP-9CC33DE5-34F8-4011-941C-FCE386F21310-600499\EtJniCapiLibrary.dll
   " java.lang.UnsatisfiedLinkError: Native Library
   C:\temp\TP-9CC33DE5-34F8-4011-941C-FCE386F21310-600499\EtJniCapiLibrary.dll
   already loaded in another classloader

This is a big problem for the customer and they would like have it fixed
in 1.4.2.  In their case, they want site A [www.portal.com] as portal , and site
B/site C  say www.financeportal.com, www.hrportal.com  to participate in
single sigon/authentication to the portal website and use their sign/encrypt
features from the applet. But if users are using CAPI/Smart Card digital
identities, it can not be done when they are using Sun Plugin JVM in their
browser.

Attached Java Console log file with trace level set to 5. (capi_native_dll_error.txt)

Comments
EVALUATION In order to make java applet to load native library, you need to set the java.library.path variable. How did you set this variable in order to load the native dll library. ###@###.### 2002-09-17 Yeah, I can easily reproduce this problem now. Just to reload the applet, you will see the UnsatisfiedLink Error in Java console. Verified. ###@###.### 2002-09-17 Due to security concern, we do not allow two different classloaders to share the same dll file (See detail comments in 4642062). If you want to share the dll file, I would suggest that you need to reuse the same classloader. However, this seems not possible for your case since it uses different URLs. ###@###.### 2002-09-17 They don't set java.library.path explicitly, just call: Runtime.getRuntime().load(libraryPath + JNI_LIBRARY_NAME) Where libraryPath + JNI_LIBRARY_NAME resolves to the absolute path of the dll, it would be in a temp folder for their case. ###@###.### 2002-09-18
18-09-2002