You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Karl Pauls (JIRA)" <ji...@apache.org> on 2008/10/10 23:37:44 UTC
[jira] Updated: (FELIX-733) Exception when uninstalling a bundle
that contains a native library (and loaded it at bundle startup).
[ https://issues.apache.org/jira/browse/FELIX-733?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Karl Pauls updated FELIX-733:
-----------------------------
Attachment: native.patch
This patch should do the trick. Could you please test it and let me know if it fixes it for you? In case you need a binary version let me know and I send you one.
> Exception when uninstalling a bundle that contains a native library (and loaded it at bundle startup).
> ------------------------------------------------------------------------------------------------------
>
> Key: FELIX-733
> URL: https://issues.apache.org/jira/browse/FELIX-733
> Project: Felix
> Issue Type: Improvement
> Components: Framework
> Environment: WinXP, eclipse, sun jdk 1.5 or 1.6
> Reporter: Sylvain MARIE
> Priority: Minor
> Attachments: native.patch
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> Here is a short description of the problem and how I managed to fix it. Don't hesitate to contact me for details
> or to tell me if something here is wrong ! Cheers. Sylvain.
> 1- bundle "foo" embeds a native library "lib.dll" and declares it in its manifest, with appropriate platform declaration (os, version, processor).
> 2- foo's activator loads that library in the start(bc) method - with System.loadLibrary(...).
> 3- the library loads succesfully (this can be checked with e.g. processExplorer or pmap)
> 4- the bundle is stopped.
> 5- the bundle is uninstalled.
> > ERROR: org.apache.felix.framework.cache.BundleArchive: Unable to delete archive directory
> Why does this happen :
> - step 4: the library is not unloaded because foo's contentclassloader is still alive. This is normal.
> - step 5: automatic package refresh : all bundles from uninstalled list are garbaged. Method
> Felix.garbageCollectBundle attemps to remove the bundle archive from the cache, but
> the dll file is still in use => ERROR. The dll is still in use because foo's contentclassloader has not yet
> been garbaged out.
> How to fix this:
> --------------------
> We need the ContentClassLoader to be garbaged out. So first release all
> references to foo's activator, then release all references to the ContentClassLoader itself,
> and finally do a System.gc() before attempting to remove the bundle from the cache.
> Two methods are impacted: ContentLoaderImpl.close() and Felix.garbageCollectBundle(...)
> ContentLoaderImpl.java
> -----------------------------------
> public synchronized void close()
> {
> ...
> ...
>
> // FIX SMA : release content class loader
> m_classLoader = null;
> }
> Felix.java
> -------------
> private void garbageCollectBundle(FelixBundle bundle) throws Exception
> {
>
> ....
>
> // FIX SMA : release reference to the activator
> bundle.getInfo().setActivator(null);
>
> // Do the garbage collection either systematically, or only if native libraries were loaded, or ...
> System.gc(); // this destroys the activator, the contentclassloader, and unloads the dll.
> // end FIX SMA
>
> // Remove the bundle from the cache.
> m_cache.remove(m_cache.getArchive(bundle.getBundleId()));
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.