

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
7 messages in net.java.dev.jna.usersRe: [jna-users] ClassLoaders and jnid...| From | Sent On | Attachments |
|---|---|---|
| Donszelmann Mark | Jun 18, 2009 7:12 am | |
| Timothy Wall | Jun 18, 2009 7:41 am | |
| Donszelmann Mark | Jun 18, 2009 9:15 am | |
| Timothy Wall | Jun 18, 2009 9:43 am | |
| LYou...@gkservices.com | Jun 18, 2009 10:30 am | .sig |
| LYou...@gkservices.com | Jun 18, 2009 10:31 am | .sig |
| Donszelmann Mark | Jun 21, 2009 6:19 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: [jna-users] ClassLoaders and jnidispatch | Actions... |
|---|---|---|
| From: | Donszelmann Mark (Mark...@slac.stanford.edu) | |
| Date: | Jun 21, 2009 6:19:44 am | |
| List: | net.java.dev.jna.users | |
Hi
we indeed fixed it by loading the library from the main classloader.
Thanks for all your help. Mark Donszelmann
On Jun 18, 2009, at 6:44 PM, Timothy Wall wrote:
On Jun 18, 2009, at 12:15 PM, Donszelmann Mark wrote:
If the class loader which loads com.sun.jna.Native is GC'd (and finalized), the native library will be unloaded , at which point another class loader can load it (this process has been improved somewhat in the code in SVN -- see JNAUnloadTest).
What is the error you are getting? What are you trying to accomplish (i.e. why is JNA being loaded more than once)?
java.lang.UnsatisfiedLinkError: jnidispatch (/com/sun/jna/win32-x86/ jnidispatch.dll) not found in resource path
we run this in a program where our users can write their own little java snippets. These we load with a ClassLoader. I guess we need to load the JNA with the system classloader so that it will be available and not unloaded.
The exception is probably hiding the real problem; if a normal System.loadLibrary("jnidispatch") fails, JNA tries to unpack it from its own jar file. It'd be helpful if you could show the original error (circa line 881 of Native.java). It's *probably* something like "library already loaded in another class loader".
If you're running in an application container, you may not have a choice where or when to load things.
we are in control. How do I make sure I load the JNA and the dll in the system classloader up front.
Currently, any class loader will reference the same jnidispatch library (since you put it in PATH); if you're going to share it like that you need to ensure the JNA classes are loaded by the system class loader.
If the class loader used to load modules has the system classloader as parent, and you put jna.jar in the classpath, then the system classloader will load it.
Alternatively, if jna.jar is bundled with your dynamically-loaded module, then JNA will extract the library from there to a temporary file and use its own copy, provided the jnidispatch library is *not* in PATH/LD_LIBRARY_PATH. Without jnidispatch in PATH, multiple modules with their own jna.jar would not conflict.
Regards Mark Donszelmann
On Jun 18, 2009, at 10:12 AM, Donszelmann Mark wrote:
Hi
we seem to have a problem loading jnidispatch.dll for the second time.
Reason is (probably) that the classloader that loads the first jna classes gets trashed.
The second classloader tries to find jnidispatch (which we have on our PATH) and does not find it.
Is this at all possible (to load jnidispatch twice), or should we make sure we load jnidispatch from a class loaded by the systemclassloader, and if so, how ?
Regards Mark Donszelmann








.sig