[
https://issues.apache.org/jira/browse/KARAF-3258?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14158109#comment-14158109
]
Andre Lanouette commented on KARAF-3258:
----------------------------------------
I think you're probably onto something. Just to make sure you can reproduce the
problem, I'll add more details on what we are doing to get this issue since
3.0.2.
We have our own "software core" kar archive that gets registered as a feature
repository in etc/org.apache.karaf.features.cfg. Then the main feature of this
kar, called "core", is added to the featuresBoot variable of the same
configuration file. This causes our main software feature to get installed at
the end of the karaf launch cycle.
Our core plugin then inspect our own configuration file for a list of kar
archives to load. These archives are passed one after the other in the correct
load order to KarService.install(). Apparently, the bundles that should start
from our kar archives features are not started when the install method returns.
We attempted to dig down in Karaf code (this is still new to us, nice and clean
code by the way ;) ) to find why the bundle do not get started right away.
Apparently, the FeatureServiceImpl startBundle method has a condition that
determines if the bundle should get started:
{code}
if (state.installed.contains(bundle)
|| (bundle.getState() != Bundle.STARTING &&
bundle.getState() != Bundle.ACTIVE
&&
bundle.adapt(BundleStartLevel.class).isPersistentlyStarted())) {
{code}
in our case, our bundles in the Kars getting started by the KarService returns
false to
{code}
bundle.adapt(BundleStartLevel.class).isPersistentlyStarted().
{code}
This causes our bundles not to get started, and the install method to return
prematurely.
If we remove our "core" kar archive from the bootFeatures variable of the
etc/org.apache.karaf.features.cfg file, and manually start it after karaf has
started,
{code}
bundle.adapt(BundleStartLevel.class).isPersistentlyStarted().
{code}
returns true, causing our bundle to get started right away and our code works
as expected.
> KarService returns immediately after Kar install
> ------------------------------------------------
>
> Key: KARAF-3258
> URL: https://issues.apache.org/jira/browse/KARAF-3258
> Project: Karaf
> Issue Type: Bug
> Components: karaf-core, karaf-kar
> Affects Versions: 3.0.2
> Reporter: Andre Lanouette
> Assignee: Jean-Baptiste Onofré
> Priority: Blocker
> Fix For: 4.0.0, 3.0.2
>
>
> In Karaf 3.0.x (up to 3.0.1), when deploying a KAR archive programatically
> using the KarService.install(URI) method , the KAR archive would get
> installed, its features would get started, and only then the method would
> return. This can be very useful when we want to control precisely a
> particular sequence of kar and service start and registration.
> With the current version of Karaf-3.0.2-SNAPSHOT, the KarService return right
> after the installation of the kar archive. Features do not get started before
> the method returns.
> This currently breaks our production build and tests because our plugin load
> order sequence cannot be guaranteed anymore.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)