You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@karaf.apache.org by "John Ellinwood (JIRA)" <ji...@apache.org> on 2015/02/03 22:37:36 UTC
[jira] [Commented] (KARAF-1729) Cannot uninstall bundle, bundle xx
is invalid
[ https://issues.apache.org/jira/browse/KARAF-1729?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14304055#comment-14304055 ]
John Ellinwood commented on KARAF-1729:
---------------------------------------
Solved. It's Regions.
When using equinox, BundleContext.getBundle(int) filters its results through NotifyHook's. The org.eclipse.equinox.region bundle registers a org.osgi.framework.hooks.bundle.FindHook that remove bundles which are not persisted in the region digraph. When this happens, bundle:list may show you have a bundle installed, but bundle:uninstall can not uninstall it because its "invalid", meaning its not in the region digraph.
Karaf Guys:
You need to persist the region digraph after the successful installation of a bundle, feature, kar, etc... not just on the shutdown of the platform. If karaf can not shutdown gracefully for any reason (which happens frequently), the only recourse a user has is to "pkill karaf". When karaf is shutdown in this fashion, the region digraph is not persisted. If a bundle was installed into karaf and did not have a chance to do a graceful shutdown to persist the region digraph, then on the next startup that bundle will be invalid.
Workaround:
feature:uninstall region
or, bundle:uninstall org.eclipse.equinox.region
just do something to get rid of the region find hook
Also, you can remove the data/digraph file from the region bundle cache and restart
Demonstration of Bug:
localhost$ karaf server
localhost$ client
karaf> install mvn:test/impl/0.0.1-SNAPSHOT #Thread.sleep() in BundleActivator.stop()
Bundle ID: 383
karaf> bundle:headers 383
Test :: Impl (383)
....
karaf> ^D
localhost> karaf stop^C #doesn't stop
localhost> pkill karaf
localhost> karaf server
karaf> bundle:headers 383
Bundle 383 is invalid
karaf> bundle:id org.eclipse.equinox.region
52
karaf> stop -f 52
karaf> bundle:headers 383
Test :: Impl (383)
....
karaf> ^D
localhost$ rm $KARAF_HOME/data/cache/org.eclipse.osgi/bundles/52/data/digraph
localhost$ client
karaf> start -f 52
karaf> bundle:headers 383
Test :: Impl (383)
....
Test Bundle:
package test.impl
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
public class Activator implements BundleActivator {
public void start(BundleContext context) {
System.out.println("Starting the bundle");
}
public void stop(BundleContext context) {
System.out.println("Stopping the bundle");
while(true) {
try { Thread.sleep(100000); } catch (Exception e) {}
}
}
}
More Details:
Between Karaf 2 and Karaf 3, the bundle: commands began using the BundleService. When the BundleService.getBundle() method is called, it will return null for an existing bundle if that bundle is not in the region digraph.
bundle:headers
--> org.apache.karaf.bundle.core.internal.BundleServiceImpl.getBundle()
--> org.apache.karaf.bundle.core.internal.BundleSelectorImpl.selectBundles()
--> org.eclipse.osgi.framework.internal.core.BundleContextImpl.getBundle()
--> notify hooks
--> org.eclipse.equinox.internal.region.hook.RegionBundleFindHook.find()
--> removes bundles not in the digraph, which is persisted to the region bundle's data location
I don't know if this is also an issue when using Felix. I could run more tests, but I hope now that I've identified the root cause, you guys can take over and determine the actual impact.
> Cannot uninstall bundle, bundle xx is invalid
> ---------------------------------------------
>
> Key: KARAF-1729
> URL: https://issues.apache.org/jira/browse/KARAF-1729
> Project: Karaf
> Issue Type: Bug
> Components: karaf-osgi
> Affects Versions: 3.0.0
> Reporter: Hendy Irawan
> Assignee: Jean-Baptiste Onofré
> Priority: Critical
> Fix For: 4.0.0, 3.0.4
>
> Attachments: karaf-invalid-bundle.tgz
>
>
> Karaf marks a bundle as installed and active, but I can't uninstall it, stop it.
> {code}
> karaf@root()> list -t 0 -s | grep pool
> [1295] [ Active] [ 50] org.apache.commons.pool (1.6.0)
> karaf@root()> uninstall 1295
> Bundle 1295 is invalid
> No bundles specified.
> karaf@root()> uninstall 1295
> Bundle 1295 is invalid
> No bundles specified.
> karaf@root()> list -t 0 -s | grep pool
> [1295] [ Active] [ 50] org.apache.commons.pool (1.6.0)
> karaf@root()> uninstall org.apache.commons.pool
> No bundles specified.
> karaf@root()> list -t 0 -s | grep pool
> [1295] [ Active] [ 50] org.apache.commons.pool (1.6.0)
> karaf@root()> stop 1295
> Bundle 1295 is invalid
> No bundles specified.
> {code}
> Workaround: Delete folder karaf/data/cache/bundle1295
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)