Hi,

Generally speaking, a feature should NOT install OSGi spec bundle as it’s 
provided by Karaf itself. So the feature is basically wrong.

However, theoretically it should work fine IF the import version ranges are 
well done, which is rarely the case for spec ;)
That’s probably why you have the invalid bundleContext: you certainly have a 
refresh happening.

In your case, I would add osgi.core/enterprise into the deny list (blacklist) 
to avoid installation of the bundles.

Regards
JB

> Le 29 sept. 2020 à 22:11, Steinar Bang <[email protected]> a écrit :
> 
> The reason I tried to make an integration test for the PostgreSQL karaf
> feature, is this issue:
> https://github.com/pgjdbc/pgjdbc/issues/1891
> 
> Short summary of the issue:
> 1. From version 42.2.13 the PostgreSQL karaf feature starts two old
>    OSGi bundles
>     <bundle>mvn:org.osgi/org.osgi.core/4.3.1</bundle>
>     <bundle>mvn:org.osgi/org.osgi.enterprise/4.2.0</bundle>
> 2. The effect this have is that if the install of the bundle is done
>    over an SSH connection, the ssh connection is torn down
> 3. Sometimes, but not always, karaf requires a restart before SSH will
>    work again
> 4. If the install of the feature is done from the console that appears
>    when karaf is started from the command line, the following stack
>    trace pops up after a couple of seconds:
> org.apache.karaf.deployer.features 
> [org.apache.karaf.deployer.features.osgi.Activator] ERROR : Invalid 
> BundleContext.
> java.lang.IllegalStateException: Invalid BundleContext.
>        at 
> org.apache.felix.framework.BundleContextImpl.checkValidity(BundleContextImpl.java:511)
>        at 
> org.apache.felix.framework.BundleContextImpl.addBundleListener(BundleContextImpl.java:211)
>        at 
> org.apache.karaf.deployer.features.FeatureDeploymentListener.init(FeatureDeploymentListener.java:89)
>        at 
> org.apache.karaf.deployer.features.osgi.Activator$DeploymentFinishedListener.deploymentEvent(Activator.java:86)
>        at 
> org.apache.karaf.features.internal.service.FeaturesServiceImpl.callListeners(FeaturesServiceImpl.java:321)
>        at 
> org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:1068)
>        at 
> org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1062)
>        at 
> org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:998)
>        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
>        at 
> java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
>        at 
> java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
>        at java.base/java.lang.Thread.run(Thread.java:834)
> 
> The stack trace does not end up in karaf.log.
> 
> So my questions are:
> 1. How bad is it to pull in a different OSGi version into a running
>    OSGi container? (I think it is bad, but I don't know exactly how
>    bad)
> 
> 2. Is there a way I can reveal the above issue in the integration test?
> 
> Here is the integration test:
> https://github.com/steinarb/pgjdbc-karaf-ci
> 
> Thanks!
> 

Reply via email to