You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Frizz <fr...@googlemail.com> on 2014/03/19 04:32:44 UTC

Classloader exception

Hi all,

I load a DLL using JNI. Because I'm still in development phase, I use
"dev:watch" to automatically update my bundle in the container.

I understood that this results in an exception: "UnsatisfiedLinkError:
Native Library xyz already loaded in another classloader" - because the DLL
is already loaded by the JVM.

I also understood that only after the classloader that loaded the DLL is
garbage collected, the DLL is unloaded.

So I uninstalled the bundle - yet I still get the UnsatisfiedLinkError
exception. Which means the classloader is still alive.

Shouldn't the bundles classloader be gone once I uninstalled the bundle?

cheers,
Frizz

Re: Classloader exception

Posted by Frizz <fr...@googlemail.com>.
Hello Marcel,

thank you for your reply.


That is exactly why OSGi has a built-in mechanism to load native code, to
> deal with such problems.


Do you mean this Bundle-NativeCode in the MANIFEST files?



> You say you are loading the DLL yourself, but did you look at the
> specification and its abilities to load native code?
>

I haven't found anything useful yet - can you point me in the right
direction?



cheers,
Frizz

Re: Classloader exception

Posted by Marcel Offermans <ma...@luminis.nl>.
Hello Frizz,

That is exactly why OSGi has a built-in mechanism to load native code, to deal with such problems. You say you are loading the DLL yourself, but did you look at the specification and its abilities to load native code?

If for some reason you really can’t use the spec for this, I suggest you study the implementation of loading native code in the Felix framework (which shows you what tricks to play) but to be honest, I would not go there but leverage what is already present.

Greetings, Marcel


On 19 Mar 2014, at 4:32 , Frizz <fr...@googlemail.com> wrote:

> Hi all,
> 
> I load a DLL using JNI. Because I'm still in development phase, I use
> "dev:watch" to automatically update my bundle in the container.
> 
> I understood that this results in an exception: "UnsatisfiedLinkError:
> Native Library xyz already loaded in another classloader" - because the DLL
> is already loaded by the JVM.
> 
> I also understood that only after the classloader that loaded the DLL is
> garbage collected, the DLL is unloaded.
> 
> So I uninstalled the bundle - yet I still get the UnsatisfiedLinkError
> exception. Which means the classloader is still alive.
> 
> Shouldn't the bundles classloader be gone once I uninstalled the bundle?
> 
> cheers,
> Frizz


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org