Karaf users,

I'm experiencing strange behavior of the concrete implementation of
the org.apache.karaf.features.FeaturesService interface in Apache
Karaf 2.3.0 (as part of JBoss Fuse 6) – please take a look at my use
case and see if you might be able to shed some light on what I’m
experiencing:

I’ve implemented an “agent” that provisions its host Karaf container
using Features (as opposed to bundles or KARs).  The agent itself is
also installed/upgraded via the Features mechanism.  I’ve recently run
into a strange issue when the agent updates itself; specifically,
after successfully self-updating to a new version (old installs new,
new uninstalls old) and restarting the container the FeaturesService
doesn’t return Features that have BundleInfo objects associated with
them.  It’s worth noting that the problem only materializes after a
restart; never before.
As a result, the agent is no longer able to correctly identify its
encapsulating Feature.  I use the following code-fragment to identify
the Feature(s) which encapsulate the agent application’s bundle:

public Set<Feature> getEncapsulatingFeatureSet() {
    Set<Feature> encapsulatingFeatureSet = new HashSet<Feature>();
    String selfBundleLocation = bundleContext.getBundle().getLocation();

    Feature[] installedFeatureArray = featuresService.listInstalledFeatures();
    for(Feature installedFeature : installedFeatureArray){
        for(BundleInfo bundleInfo : installedFeature.getBundles()){
            if(selfBundleLocation.equals(bundleInfo.getLocation())){
                encapsulatingFeatureSet.add(installedFeature);
                logger.info("Encapsulating Feature detected --> " +
installedFeature.getName() + "/" + installedFeature.getVersion());
                break;
            }
        }
    }

    return Collections.unmodifiableSet(encapsulatingFeatureSet);
}

This has always worked very well and I haven’t had any prior issues.
However, after restarting post-update the List of installed Features
returned by FeaturesService.listInstalledFeatures() do not show up as
having any BundleInfo objects associated with them (for both OOTB and
custom Features) as retrieved by Feature.getBundles().

I admit I’m at a loss to explain why I’m receiving what can only be
described as invalid data (I know these Features should have
BundleInfo objects associated with them).  I’m hoping someone might be
able to shed some light on why the FeaturesService is seemingly
behaving strangely (if its operator-error please let me know), and
then only after a restart.


Thank you for your time,

-Steve

Reply via email to