You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Laci Gaspar <la...@gmail.com> on 2015/04/09 17:20:34 UTC

wiring

Hi
I have a question about how wiring works in karaf:

I have the following bundles installed:

bundle-abc, version 1.1
bundle-xyz, version 1.2
lib, version 1.1
lib, version 1.2

bundle-abc uses classes from lib version 1.1
bundle-xyz uses classes from lib version 1.2
these dependencies are defined in the pom files of the bundles.

Now if I do an update (in the karaf shell, keeping the versions) on say 
bundle-xyz, it can happen, that bundle-xyz is wired with lib version 1.1.

Is this normal behavior? or is it a bad Idea to have two different 
versions of lib installed?

Thanks
Laci


Re: wiring

Posted by Laci Gaspar <la...@gmail.com>.
Hi

I figured it out. It's because I didn't specify a range of versions. 
Just version=${project.version}.
In that case the upper boundery of the versions is interpreted as infinite.

thanks for your help.
Laci

On 05.05.2015 20:45, chris.gray@kiffer.ltd.uk wrote:
> The wiring depends on the headers in your bundle's manifest.  If they say
> for example to import ch.curabill.msp.service version 1.4.2 (inclusive) to
> version 2.0.0 (exclusive) then the framework is perfectly entitled to wire
> it to 1.5.2 and indeed it should be congratulated for doing so if this
> reduces the number of versions of ch.curabill.msp.service installed (for
> example because another bundle insisted on >=1.5).
>
> The first step is to look in the manifest to see what the Import-Package:
> header says, and the second is maybe to figure out just *why* it says
> that. Generally the minimum version would be the version your bundle was
> compiled against, up to but not including the next "major" version.
>
>> Hi
>> there's still something I don't understand.
>> In my pom of bundle A, I have the following now:
>>
>>       <Import-Package>
>>           ch.curabill*;version=${project.version},
>>           *
>>       </Import-Package>
>>
>> After installing bundle A Version 1.4.2-SNAPSHOT, I do a imports <bundle
>> A id>, and I get
>> ...
>> MspServiceMessages (964): ch.curabill.msp.service; version=1.5.2.SNAPSHOT
>> ...
>>
>> The bundle MspServiceMessages is installed in versions 1.4.2-SNAPSHOT
>> and 1.5.2.SNAPSHOT.
>>
>> Why is bundle A wired with bundle MspServiceMessages, version
>> 1.5.2.SNAPSHOT???
>>
>> thanks for your help,
>> Laci
>>
>> On 10.04.2015 13:07, Jamie G. wrote:
>>> No problem :)
>>>
>>> You might enjoy looking through the code examples from the Apache
>>> Karaf Cookbook:
>>> https://github.com/jgoodyear/ApacheKarafCookbook
>>>
>>> Full disclosure, i worked on that book - but the sample code is freely
>>> available on github, so have a look - might help jump start your
>>> development.
>>>
>>> Cheers,
>>> Jamie
>>>
>>
>


Re: wiring

Posted by ch...@kiffer.ltd.uk.
The wiring depends on the headers in your bundle's manifest.  If they say
for example to import ch.curabill.msp.service version 1.4.2 (inclusive) to
version 2.0.0 (exclusive) then the framework is perfectly entitled to wire
it to 1.5.2 and indeed it should be congratulated for doing so if this
reduces the number of versions of ch.curabill.msp.service installed (for
example because another bundle insisted on >=1.5).

The first step is to look in the manifest to see what the Import-Package:
header says, and the second is maybe to figure out just *why* it says
that. Generally the minimum version would be the version your bundle was
compiled against, up to but not including the next "major" version.

> Hi
> there's still something I don't understand.
> In my pom of bundle A, I have the following now:
>
>      <Import-Package>
>          ch.curabill*;version=${project.version},
>          *
>      </Import-Package>
>
> After installing bundle A Version 1.4.2-SNAPSHOT, I do a imports <bundle
> A id>, and I get
> ...
> MspServiceMessages (964): ch.curabill.msp.service; version=1.5.2.SNAPSHOT
> ...
>
> The bundle MspServiceMessages is installed in versions 1.4.2-SNAPSHOT
> and 1.5.2.SNAPSHOT.
>
> Why is bundle A wired with bundle MspServiceMessages, version
> 1.5.2.SNAPSHOT???
>
> thanks for your help,
> Laci
>
> On 10.04.2015 13:07, Jamie G. wrote:
>> No problem :)
>>
>> You might enjoy looking through the code examples from the Apache
>> Karaf Cookbook:
>> https://github.com/jgoodyear/ApacheKarafCookbook
>>
>> Full disclosure, i worked on that book - but the sample code is freely
>> available on github, so have a look - might help jump start your
>> development.
>>
>> Cheers,
>> Jamie
>>
>
>



Re: wiring

Posted by Laci Gaspar <la...@gmail.com>.
Hi
there's still something I don't understand.
In my pom of bundle A, I have the following now:

     <Import-Package>
         ch.curabill*;version=${project.version},
         *
     </Import-Package>

After installing bundle A Version 1.4.2-SNAPSHOT, I do a imports <bundle 
A id>, and I get
...
MspServiceMessages (964): ch.curabill.msp.service; version=1.5.2.SNAPSHOT
...

The bundle MspServiceMessages is installed in versions 1.4.2-SNAPSHOT 
and 1.5.2.SNAPSHOT.

Why is bundle A wired with bundle MspServiceMessages, version 
1.5.2.SNAPSHOT???

thanks for your help,
Laci

On 10.04.2015 13:07, Jamie G. wrote:
> No problem :)
>
> You might enjoy looking through the code examples from the Apache
> Karaf Cookbook:
> https://github.com/jgoodyear/ApacheKarafCookbook
>
> Full disclosure, i worked on that book - but the sample code is freely
> available on github, so have a look - might help jump start your
> development.
>
> Cheers,
> Jamie
>


Re: wiring

Posted by "Jamie G." <ja...@gmail.com>.
No problem :)

You might enjoy looking through the code examples from the Apache
Karaf Cookbook:
https://github.com/jgoodyear/ApacheKarafCookbook

Full disclosure, i worked on that book - but the sample code is freely
available on github, so have a look - might help jump start your
development.

Cheers,
Jamie

On Fri, Apr 10, 2015 at 8:17 AM, Laci Gaspar <la...@gmail.com> wrote:
> Thanks for your explenation.
> Your and Jamie G.'s question already points me to my mistake.
> There is no wiring information in my pom. I have no import / export
> directives there.
>
> So, I'll try to add them there and test again.
>
> Thanks!
> Laci
>
>
>
>
> On 09.04.2015 17:37, David Bosschaert wrote:
>>
>> In general it is possible to have multiple versions of the same
>> library installed, this is totally fine in OSGi and therefore also in
>> Karaf. Depending on your import version range you are wired to one or
>> the other.
>>
>> I just wanted to note that if you do an update of a bundle that this
>> does not automatically percolate to bundles that are wired to it.
>>
>> Let's say you have a bundle A that exports a.b.c.SomeClass version 1
>> and a bundle B that imports a.b.c.SomeClass version [1, 2).
>> Now if you update bundle A so that it now exports a.b.c.SomeClass
>> version 2 instead, bundle B will still import the a.b.c.SomeClass
>> version 1 from the previous revision of your bundle A. In OSGi this is
>> modeled via BundleRevisions. When there are still bundles wired to the
>> previous version of a bundle these revisions stick around, until the
>> bundles wired to them (in the example bundle B) are refreshed. When
>> you're refresh bundle B in my example here you would see that it
>> doesn't resolve any more since that package is now not available any
>> more in the range [1, 2).
>>
>> However, to comment on your specific example we'd need the import
>> ranges as Jamie suggests.
>>
>> Best regards,
>>
>> David
>>
>> On 9 April 2015 at 16:28, Jamie G. <ja...@gmail.com> wrote:
>>>
>>> Please supply your bundle wiring info - which ranges are configured?
>>>
>>> On Thu, Apr 9, 2015 at 12:50 PM, Laci Gaspar <la...@gmail.com> wrote:
>>>>
>>>> Hi
>>>> I have a question about how wiring works in karaf:
>>>>
>>>> I have the following bundles installed:
>>>>
>>>> bundle-abc, version 1.1
>>>> bundle-xyz, version 1.2
>>>> lib, version 1.1
>>>> lib, version 1.2
>>>>
>>>> bundle-abc uses classes from lib version 1.1
>>>> bundle-xyz uses classes from lib version 1.2
>>>> these dependencies are defined in the pom files of the bundles.
>>>>
>>>> Now if I do an update (in the karaf shell, keeping the versions) on say
>>>> bundle-xyz, it can happen, that bundle-xyz is wired with lib version
>>>> 1.1.
>>>>
>>>> Is this normal behavior? or is it a bad Idea to have two different
>>>> versions
>>>> of lib installed?
>>>>
>>>> Thanks
>>>> Laci
>>>>
>

Re: wiring

Posted by Laci Gaspar <la...@gmail.com>.
Thanks for your explenation.
Your and Jamie G.'s question already points me to my mistake.
There is no wiring information in my pom. I have no import / export 
directives there.

So, I'll try to add them there and test again.

Thanks!
Laci



On 09.04.2015 17:37, David Bosschaert wrote:
> In general it is possible to have multiple versions of the same
> library installed, this is totally fine in OSGi and therefore also in
> Karaf. Depending on your import version range you are wired to one or
> the other.
>
> I just wanted to note that if you do an update of a bundle that this
> does not automatically percolate to bundles that are wired to it.
>
> Let's say you have a bundle A that exports a.b.c.SomeClass version 1
> and a bundle B that imports a.b.c.SomeClass version [1, 2).
> Now if you update bundle A so that it now exports a.b.c.SomeClass
> version 2 instead, bundle B will still import the a.b.c.SomeClass
> version 1 from the previous revision of your bundle A. In OSGi this is
> modeled via BundleRevisions. When there are still bundles wired to the
> previous version of a bundle these revisions stick around, until the
> bundles wired to them (in the example bundle B) are refreshed. When
> you're refresh bundle B in my example here you would see that it
> doesn't resolve any more since that package is now not available any
> more in the range [1, 2).
>
> However, to comment on your specific example we'd need the import
> ranges as Jamie suggests.
>
> Best regards,
>
> David
>
> On 9 April 2015 at 16:28, Jamie G. <ja...@gmail.com> wrote:
>> Please supply your bundle wiring info - which ranges are configured?
>>
>> On Thu, Apr 9, 2015 at 12:50 PM, Laci Gaspar <la...@gmail.com> wrote:
>>> Hi
>>> I have a question about how wiring works in karaf:
>>>
>>> I have the following bundles installed:
>>>
>>> bundle-abc, version 1.1
>>> bundle-xyz, version 1.2
>>> lib, version 1.1
>>> lib, version 1.2
>>>
>>> bundle-abc uses classes from lib version 1.1
>>> bundle-xyz uses classes from lib version 1.2
>>> these dependencies are defined in the pom files of the bundles.
>>>
>>> Now if I do an update (in the karaf shell, keeping the versions) on say
>>> bundle-xyz, it can happen, that bundle-xyz is wired with lib version 1.1.
>>>
>>> Is this normal behavior? or is it a bad Idea to have two different versions
>>> of lib installed?
>>>
>>> Thanks
>>> Laci
>>>


Re: wiring

Posted by David Bosschaert <da...@gmail.com>.
In general it is possible to have multiple versions of the same
library installed, this is totally fine in OSGi and therefore also in
Karaf. Depending on your import version range you are wired to one or
the other.

I just wanted to note that if you do an update of a bundle that this
does not automatically percolate to bundles that are wired to it.

Let's say you have a bundle A that exports a.b.c.SomeClass version 1
and a bundle B that imports a.b.c.SomeClass version [1, 2).
Now if you update bundle A so that it now exports a.b.c.SomeClass
version 2 instead, bundle B will still import the a.b.c.SomeClass
version 1 from the previous revision of your bundle A. In OSGi this is
modeled via BundleRevisions. When there are still bundles wired to the
previous version of a bundle these revisions stick around, until the
bundles wired to them (in the example bundle B) are refreshed. When
you're refresh bundle B in my example here you would see that it
doesn't resolve any more since that package is now not available any
more in the range [1, 2).

However, to comment on your specific example we'd need the import
ranges as Jamie suggests.

Best regards,

David

On 9 April 2015 at 16:28, Jamie G. <ja...@gmail.com> wrote:
> Please supply your bundle wiring info - which ranges are configured?
>
> On Thu, Apr 9, 2015 at 12:50 PM, Laci Gaspar <la...@gmail.com> wrote:
>> Hi
>> I have a question about how wiring works in karaf:
>>
>> I have the following bundles installed:
>>
>> bundle-abc, version 1.1
>> bundle-xyz, version 1.2
>> lib, version 1.1
>> lib, version 1.2
>>
>> bundle-abc uses classes from lib version 1.1
>> bundle-xyz uses classes from lib version 1.2
>> these dependencies are defined in the pom files of the bundles.
>>
>> Now if I do an update (in the karaf shell, keeping the versions) on say
>> bundle-xyz, it can happen, that bundle-xyz is wired with lib version 1.1.
>>
>> Is this normal behavior? or is it a bad Idea to have two different versions
>> of lib installed?
>>
>> Thanks
>> Laci
>>

Re: wiring

Posted by "Jamie G." <ja...@gmail.com>.
Please supply your bundle wiring info - which ranges are configured?

On Thu, Apr 9, 2015 at 12:50 PM, Laci Gaspar <la...@gmail.com> wrote:
> Hi
> I have a question about how wiring works in karaf:
>
> I have the following bundles installed:
>
> bundle-abc, version 1.1
> bundle-xyz, version 1.2
> lib, version 1.1
> lib, version 1.2
>
> bundle-abc uses classes from lib version 1.1
> bundle-xyz uses classes from lib version 1.2
> these dependencies are defined in the pom files of the bundles.
>
> Now if I do an update (in the karaf shell, keeping the versions) on say
> bundle-xyz, it can happen, that bundle-xyz is wired with lib version 1.1.
>
> Is this normal behavior? or is it a bad Idea to have two different versions
> of lib installed?
>
> Thanks
> Laci
>