You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by simplemind <pa...@gmail.com> on 2011/07/20 07:39:40 UTC

Feature Dependencies load order

I take it that if you say a feature is dependent on another feature then the
dependent feature is loaded after the feature it depends on is completely
loaded?  Can you specify a start-level for a feature?

Also, for bundle start-level, is a higher number higher load priority or
lower load priority?  The docs do not specify this.  Docs seem to say
default start level is 60 if you do not specify?

As you may have guessed I am having some trouble with features not loading
properly all the time.  Like if I load each of the features one at a time it
works, but if I load the A, where A depends on B and B depends on C, it
seems to break somewhere in the chain.  I can't discern a pattern.  But
there is a bundle in A that is the only thing that runs anything, and it
usually breaks in B with a missing dependency between 2 B packages.  Like it
is running A before B is completely loaded.

--
View this message in context: http://karaf.922171.n3.nabble.com/Feature-Dependencies-load-order-tp3184561p3184561.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Feature Dependencies load order

Posted by mikevan <mv...@comcast.net>.
David/Simplemind,

I just confirmed that wrap: does mark all imports as resolution:=optional. 

It should be noted that for this reason "wrap:" shouldn't be the solution
for a "live" system.  Instead, use it to identify all of the .jar files your
system needs, and then prior to going live, "wrap" all of the non-osgi .jar
files your application needs using BND.  Peter Kriens has a lot of good
information on his website about how to do this, and it also provides a lot
of general information about OSGi from a developer's perspective.
http://www.aqute.biz/Main/HomePage

Please let me know if this answers your questions. 


David Jencks wrote:
> 
> On Jul 20, 2011, at 10:02 AM, simplemind wrote:
> 
>> I have discovered the problem.  Actually it is 2 issues, one is with
>> webconsole and the other is with wrap.  I am still not sure about
>> start-priority, but I think lower number means lower priority.
> 
> The startlevel service starts at priority 1 (or 0, I'm not sure) and loads
> all the bundles at that level, starts them, increases the start level by
> one, and repeats until done.
>> 
>> The problem with webconsole is that it times out.   If you click on load
>> a
>> feature that takes a while to load the webconsole request times out and
>> kills the feature load at whatever point it happens to be.  For instance,
>> in
>> karaf 2.2.2 on my machine I cannot even load the 'war' feature from the
>> webconsole because it just takes too long.
>> 
>> The second issue is a really strange one with wrap.  Suppose bundle A
>> exports a package a.a.a.  And suppose B is a wrapped (legacy jar) bundle. 
>> If I make a feature that has B before A and load the feature and look at
>> B
>> it shows a.a.a as an optional import in the manifest headers, plus a.a.a
>> was
>> not imported.  But if you load a feature that has A before B, then the
>> loaded B has a.a.a in the Imports.
>> 
>> Easy enough to work around these, but they are both big "gochas" that had
>> me
>> confused in combination for a few wasted hours.  If anyone cares to
>> explain
>> how wrap is determining what are optional imports I would be interested. 
>> Seems like a bug, because in my case a.a.a was being used and should have
>> been imported no matter the load order.  Also, why does wrapped bundle
>> link
>> optional imports if they happen to already be loaded into karaf when the
>> bundle is loaded?
> 
> I think wrap marks all imports as optional.  This is sort of reasonable if
> you have no idea what the jar does and what actually is optional, but
> obviously ridiculous if you do know what the jar does.  So, its a good
> idea to actually look into the contents and figure out what is optional
> and what isn't.  You can then write a "bundleizing" maven project that
> repackages the jar as a bundle or (I think, I never tried it) provide a
> lot of info in the wrap url telling bnd what to do.
> 
> Optional package imports work like this: if the optional package happens
> to be available when the bundle starts, it's wired in.  If it doesn't
> happen to be available, it is not wired in even if the package becomes
> available later, and if you want to get it wired in you have  to refresh
> the bundle with the optional import.  So you are observing the normal
> optional package import behavior.
> 
> You can also use dynamic-import-package which will check for the package
> every time you try to use the wire, but this can have performance
> implications.
> 
> hope this helps....
> david jencks
> 
>> 
>> --
>> View this message in context:
>> http://karaf.922171.n3.nabble.com/Feature-Dependencies-load-order-tp3184561p3185973.html
>> Sent from the Karaf - User mailing list archive at Nabble.com.
> 


-----
Mike Van
--
View this message in context: http://karaf.922171.n3.nabble.com/Feature-Dependencies-load-order-tp3184561p3186648.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Feature Dependencies load order

Posted by David Jencks <da...@yahoo.com>.
On Jul 20, 2011, at 10:02 AM, simplemind wrote:

> I have discovered the problem.  Actually it is 2 issues, one is with
> webconsole and the other is with wrap.  I am still not sure about
> start-priority, but I think lower number means lower priority.

The startlevel service starts at priority 1 (or 0, I'm not sure) and loads all the bundles at that level, starts them, increases the start level by one, and repeats until done.
> 
> The problem with webconsole is that it times out.   If you click on load a
> feature that takes a while to load the webconsole request times out and
> kills the feature load at whatever point it happens to be.  For instance, in
> karaf 2.2.2 on my machine I cannot even load the 'war' feature from the
> webconsole because it just takes too long.
> 
> The second issue is a really strange one with wrap.  Suppose bundle A
> exports a package a.a.a.  And suppose B is a wrapped (legacy jar) bundle. 
> If I make a feature that has B before A and load the feature and look at B
> it shows a.a.a as an optional import in the manifest headers, plus a.a.a was
> not imported.  But if you load a feature that has A before B, then the
> loaded B has a.a.a in the Imports.
> 
> Easy enough to work around these, but they are both big "gochas" that had me
> confused in combination for a few wasted hours.  If anyone cares to explain
> how wrap is determining what are optional imports I would be interested. 
> Seems like a bug, because in my case a.a.a was being used and should have
> been imported no matter the load order.  Also, why does wrapped bundle link
> optional imports if they happen to already be loaded into karaf when the
> bundle is loaded?

I think wrap marks all imports as optional.  This is sort of reasonable if you have no idea what the jar does and what actually is optional, but obviously ridiculous if you do know what the jar does.  So, its a good idea to actually look into the contents and figure out what is optional and what isn't.  You can then write a "bundleizing" maven project that repackages the jar as a bundle or (I think, I never tried it) provide a lot of info in the wrap url telling bnd what to do.

Optional package imports work like this: if the optional package happens to be available when the bundle starts, it's wired in.  If it doesn't happen to be available, it is not wired in even if the package becomes available later, and if you want to get it wired in you have  to refresh the bundle with the optional import.  So you are observing the normal optional package import behavior.

You can also use dynamic-import-package which will check for the package every time you try to use the wire, but this can have performance implications.

hope this helps....
david jencks

> 
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Feature-Dependencies-load-order-tp3184561p3185973.html
> Sent from the Karaf - User mailing list archive at Nabble.com.


Re: Feature Dependencies load order

Posted by simplemind <pa...@gmail.com>.
I have discovered the problem.  Actually it is 2 issues, one is with
webconsole and the other is with wrap.  I am still not sure about
start-priority, but I think lower number means lower priority.

The problem with webconsole is that it times out.   If you click on load a
feature that takes a while to load the webconsole request times out and
kills the feature load at whatever point it happens to be.  For instance, in
karaf 2.2.2 on my machine I cannot even load the 'war' feature from the
webconsole because it just takes too long.

The second issue is a really strange one with wrap.  Suppose bundle A
exports a package a.a.a.  And suppose B is a wrapped (legacy jar) bundle. 
If I make a feature that has B before A and load the feature and look at B
it shows a.a.a as an optional import in the manifest headers, plus a.a.a was
not imported.  But if you load a feature that has A before B, then the
loaded B has a.a.a in the Imports.

Easy enough to work around these, but they are both big "gochas" that had me
confused in combination for a few wasted hours.  If anyone cares to explain
how wrap is determining what are optional imports I would be interested. 
Seems like a bug, because in my case a.a.a was being used and should have
been imported no matter the load order.  Also, why does wrapped bundle link
optional imports if they happen to already be loaded into karaf when the
bundle is loaded?

--
View this message in context: http://karaf.922171.n3.nabble.com/Feature-Dependencies-load-order-tp3184561p3185973.html
Sent from the Karaf - User mailing list archive at Nabble.com.