You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Thomas Vandahl <tv...@apache.org> on 2017/02/05 09:53:33 UTC

Karaf feature how-to?

Hi folks,

I'm a newbie in the OSGi area, so please excuse if I ask silly
questions. However, even intensive googling did not help.

We've created an application that consists of eight bundles based on
Camel, CXF and Blueprint. We could run it in Karaf 4.0.7 just fine when
all dependency features/bundles were installed manually.

The obvious idea was to combine all bundles and their dependencies in a
Karaf-feature for automatic installation. From reading the docs, I
thought that having my bundles as dependencies of the feature artifact
would do the trick. The feature file looked promising but Karaf could
not resolve several packages, nor could I get the feature to
karaf:verify successfully.

What else did I try:
- building the feature file by hand as an exact copy of what had been
done manually at the Karaf console -> no success (the usual suspects you
find when searching the internet: missing blueprint container, spring
beans, jaxb AnnotationReader, aop alliance Advice etc)
- reducing the complexity to just one basic bundle -> no success
- defining boot-features and prerequisites as mentioned in some postings
-> no success
- adding required features as Maven dependencies -> no success
- copy the structure of existing feature files -> no success
- build a KAR instead of a feature -> no success

Did I even get the whole idea right? Could you please point me to a
tutorial-kind-of-thing that explains step by step how a feature artifact
is supposed to work? Or to some help with debugging?

Thanks in advance for any hint you can give.
Bye, Thomas

Re: Karaf feature how-to?

Posted by Thomas Vandahl <tv...@apache.org>.
Hi Dominik,

On 05.02.17 11:27, Dominik Przybysz wrote:
> Look at my simple example here:
> https://github.com/alien11689/feature-toggle/tree/master/featuretoogle-karaf-feature
> <https://github.com/alien11689/feature-toggle/tree/master/featuretoogle-karaf-feature>

Ok, I see from your example that you wrote your feature.xml manually.
You do not refer to any dependencies in the POM. From the docs I
understood that putting the dependencies in your POM should be
equivalent to what you wrote and the feature.xml file should be
generated automatically. Like, instead of:

<bundle
start-level="80">mvn:com.github.alien11689.osgi.featuretoogle/com.github.alien11689.osgi.feature-toggle-api/1.0-SNAPSHOT</bundle>
        <bundle
start-level="80">mvn:com.github.alien11689.osgi.featuretoogle/com.github.alien11689.osgi.feature-toggle-impl/1.0-SNAPSHOT</bundle>

the POM should contain

<dependency>
    <groupId>com.github.alien11689.osgi.featuretoogle</groupId>
    <artifactId>com.github.alien11689.osgi.feature-toggle-api</artifactId>
    <version>1.0-SNAPSHOT</version>
    <type>bundle</type>
</dependency>
<dependency>
    <groupId>com.github.alien11689.osgi.featuretoogle</groupId>
    <artifactId>com.github.alien11689.osgi.feature-toggle-impl</artifactId>
    <version>1.0-SNAPSHOT</version>
    <type>bundle</type>
</dependency>

This somehow works for our application but the resulting feature.xml
does not resolve all dependencies, especially not those that are
supposed to exist already in Karaf as you mentioned.

I hope it is possible to understand what I'm trying to achieve.

Bye, Thomas

Re: Karaf feature how-to?

Posted by Dominik Przybysz <al...@gmail.com>.
Hi,
you should create feature, which contains all your bundles and all the
features your bundle needs. There are cxf and camel features. Blueprint
should be installed by default in Karaf.

If feature definition is missing on karaf (e.g. camel) then you should add
repository containing it via:

<repository>mvn:org.apache.camel.karaf/apache-camel/2.17.
1/xml/features</repository>

If other bundles are still missing then you should find features which
contains such bundles and add feature enrty in xml or write bundle entry
instead.

Look at my simple example here:
https://github.com/alien11689/feature-toggle/tree/master/
featuretoogle-karaf-feature

I think your feature xml should be similar to:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"
name="your_features_repo_name">
    <feature name="your_feature_name" description="..." version="...">
        <repository>mvn:org.apache.
camel.karaf/apache-camel/your_camel_version/xml/features</repository>
        <feature dependency="camel">wrap</feature>
        <feature dependency="cxf">wrap</feature>
        <bundle start-level="80">your_bundle</bundle>
        ...
    </feature>
</features>

2017-02-05 10:53 GMT+01:00 Thomas Vandahl <tv...@apache.org>:

> Hi folks,
>
> I'm a newbie in the OSGi area, so please excuse if I ask silly
> questions. However, even intensive googling did not help.
>
> We've created an application that consists of eight bundles based on
> Camel, CXF and Blueprint. We could run it in Karaf 4.0.7 just fine when
> all dependency features/bundles were installed manually.
>
> The obvious idea was to combine all bundles and their dependencies in a
> Karaf-feature for automatic installation. From reading the docs, I
> thought that having my bundles as dependencies of the feature artifact
> would do the trick. The feature file looked promising but Karaf could
> not resolve several packages, nor could I get the feature to
> karaf:verify successfully.
>
> What else did I try:
> - building the feature file by hand as an exact copy of what had been
> done manually at the Karaf console -> no success (the usual suspects you
> find when searching the internet: missing blueprint container, spring
> beans, jaxb AnnotationReader, aop alliance Advice etc)
> - reducing the complexity to just one basic bundle -> no success
> - defining boot-features and prerequisites as mentioned in some postings
> -> no success
> - adding required features as Maven dependencies -> no success
> - copy the structure of existing feature files -> no success
> - build a KAR instead of a feature -> no success
>
> Did I even get the whole idea right? Could you please point me to a
> tutorial-kind-of-thing that explains step by step how a feature artifact
> is supposed to work? Or to some help with debugging?
>
> Thanks in advance for any hint you can give.
> Bye, Thomas
>



-- 
Pozdrawiam / Regards,
Dominik Przybysz

Re: Karaf feature how-to?

Posted by James Carman <ja...@carmanconsulting.com>.
Sorry for top-posting, but I'm on my phone.  Yeah, ideally, the plugin
would translate perfectly from the Maven world into the Karaf world, but
that just hasn't been my experience, so I just do it by hand and, for me,
it's not a huge burden.  Yes, there are times when things get screwed up,
but it hasn't annoyed me enough at this point to sit down and write a
patch. :)  This is just my experience.  Others may have been able to get
better mileage out of the plugin.  If so, I'm all for automation!

James


On Mon, Feb 13, 2017 at 12:20 PM Thomas Vandahl <tv...@apache.org> wrote:

> Hi James,
>
> On 12.02.17 14:39, James Carman wrote:
> > I always build my features by hand.  It's just easier, IMHO.  A few
> > errors on the console telling you what's missing, and you're off to the
> > races.  You can also try using PAX exam to test your features, but I've
> > found that to be more trouble than it's worth (it always chooses to fail
> > when I'm trying to do something important, like cut a release).
>
> You are probably right, but something inside me refuses to accept that
> if my dependency management are good enough for Maven they still are not
> good enough for Karaf. This manual editing adds a possibility for failure.
>
> Bye, Thomas
>

Re: Karaf feature how-to?

Posted by Thomas Vandahl <tv...@apache.org>.
Hi James,

On 12.02.17 14:39, James Carman wrote:
> I always build my features by hand.  It's just easier, IMHO.  A few
> errors on the console telling you what's missing, and you're off to the
> races.  You can also try using PAX exam to test your features, but I've
> found that to be more trouble than it's worth (it always chooses to fail
> when I'm trying to do something important, like cut a release).  

You are probably right, but something inside me refuses to accept that
if my dependency management are good enough for Maven they still are not
good enough for Karaf. This manual editing adds a possibility for failure.

Bye, Thomas

Re: Karaf feature how-to?

Posted by James Carman <ja...@carmanconsulting.com>.
I always build my features by hand.  It's just easier, IMHO.  A few errors
on the console telling you what's missing, and you're off to the races.
You can also try using PAX exam to test your features, but I've found that
to be more trouble than it's worth (it always chooses to fail when I'm
trying to do something important, like cut a release).


On Sun, Feb 12, 2017 at 8:31 AM Thomas Vandahl <tv...@apache.org> wrote:

> Hi Jean-Baptiste,
>
> On 05.02.17 16:36, Thomas Vandahl wrote:
> > Reading this makes me think that the list of Maven dependencies
> > (including transitive ones) should be sufficient to resolve everything.
> > Is this a valid assumption to make? The karaf-maven-plugin gives me for
> > example
> >
> > <bundle>mvn:org.apache.camel/camel-blueprint/2.18.1</bundle>
> >
> > Is this identical to
> >
> > <feature version="2.18.1">camel-blueprint</feature>
> >
> > and if not, how do I get the plugin to generate the latter from a
> > dependency entry in the POM? Is this possible at all or do I need to
> > manage the feature dependencies manually?
>
> Ok, I got my feature artifact to verify successfully. Upgrading to Karaf
> 4.0.8 helped a lot. The error messages are much more helpful.
>
> However, it was *not* possible to get the feature to verify without
> adding feature dependencies to the feature.xml-template such as
> aries-blueprint, aries-proxy, eventadmin and spring - even though most
> of them were listed as wrapped bundles in the dependency tree. Moreover,
> I had to add the standard-feature-descriptor and the
> spring-feature-descriptor as "runtime"-dependencies to the POM.
>
> One last thing I learned was that a bundle dependency of
> camel-ftp/2.18.1 is obviously not identical to a feature dependency of
> camel-ftp. In the first case, the Karaf Maven plugin complains about a
> missing dependency to com.jcraft.jsch.*, in the second case, it doesn't.
>
> I now have a verified feature file but when I try to install it in a
> clean Karaf 4.0.8 instance, all cores go up to 100% and nothing else
> happens. No entries in the log file, no network activity, just CPU. I
> gave up after a little bit over an hour.
>
> Could you please explain how this is supposed to work and what debug
> approach would be the best? I can provide my code examples if you want,
> I'm just a bit reluctant to post them here.
>
> Bye, Thomas.
>
>

Re: Karaf feature how-to?

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Thomas

Bundle in a feature just installs the bundle assuming all requirements and dependencies for this bundle are there.
That's why you can install a feature instead bringing all requirements.

I'm in vacation for couple of days, I will get back to you for more details next week.

Regards
JB

On Feb 12, 2017, 09:31, at 09:31, Thomas Vandahl <tv...@apache.org> wrote:
>Hi Jean-Baptiste,
>
>On 05.02.17 16:36, Thomas Vandahl wrote:
>> Reading this makes me think that the list of Maven dependencies
>> (including transitive ones) should be sufficient to resolve
>everything.
>> Is this a valid assumption to make? The karaf-maven-plugin gives me
>for
>> example
>> 
>> <bundle>mvn:org.apache.camel/camel-blueprint/2.18.1</bundle>
>> 
>> Is this identical to
>> 
>> <feature version="2.18.1">camel-blueprint</feature>
>> 
>> and if not, how do I get the plugin to generate the latter from a
>> dependency entry in the POM? Is this possible at all or do I need to
>> manage the feature dependencies manually?
>
>Ok, I got my feature artifact to verify successfully. Upgrading to
>Karaf
>4.0.8 helped a lot. The error messages are much more helpful.
>
>However, it was *not* possible to get the feature to verify without
>adding feature dependencies to the feature.xml-template such as
>aries-blueprint, aries-proxy, eventadmin and spring - even though most
>of them were listed as wrapped bundles in the dependency tree.
>Moreover,
>I had to add the standard-feature-descriptor and the
>spring-feature-descriptor as "runtime"-dependencies to the POM.
>
>One last thing I learned was that a bundle dependency of
>camel-ftp/2.18.1 is obviously not identical to a feature dependency of
>camel-ftp. In the first case, the Karaf Maven plugin complains about a
>missing dependency to com.jcraft.jsch.*, in the second case, it
>doesn't.
>
>I now have a verified feature file but when I try to install it in a
>clean Karaf 4.0.8 instance, all cores go up to 100% and nothing else
>happens. No entries in the log file, no network activity, just CPU. I
>gave up after a little bit over an hour.
>
>Could you please explain how this is supposed to work and what debug
>approach would be the best? I can provide my code examples if you want,
>I'm just a bit reluctant to post them here.
>
>Bye, Thomas.

Re: Karaf feature how-to?

Posted by Thomas Vandahl <tv...@apache.org>.
Hi Jean-Baptiste,

On 05.02.17 16:36, Thomas Vandahl wrote:
> Reading this makes me think that the list of Maven dependencies
> (including transitive ones) should be sufficient to resolve everything.
> Is this a valid assumption to make? The karaf-maven-plugin gives me for
> example
> 
> <bundle>mvn:org.apache.camel/camel-blueprint/2.18.1</bundle>
> 
> Is this identical to
> 
> <feature version="2.18.1">camel-blueprint</feature>
> 
> and if not, how do I get the plugin to generate the latter from a
> dependency entry in the POM? Is this possible at all or do I need to
> manage the feature dependencies manually?

Ok, I got my feature artifact to verify successfully. Upgrading to Karaf
4.0.8 helped a lot. The error messages are much more helpful.

However, it was *not* possible to get the feature to verify without
adding feature dependencies to the feature.xml-template such as
aries-blueprint, aries-proxy, eventadmin and spring - even though most
of them were listed as wrapped bundles in the dependency tree. Moreover,
I had to add the standard-feature-descriptor and the
spring-feature-descriptor as "runtime"-dependencies to the POM.

One last thing I learned was that a bundle dependency of
camel-ftp/2.18.1 is obviously not identical to a feature dependency of
camel-ftp. In the first case, the Karaf Maven plugin complains about a
missing dependency to com.jcraft.jsch.*, in the second case, it doesn't.

I now have a verified feature file but when I try to install it in a
clean Karaf 4.0.8 instance, all cores go up to 100% and nothing else
happens. No entries in the log file, no network activity, just CPU. I
gave up after a little bit over an hour.

Could you please explain how this is supposed to work and what debug
approach would be the best? I can provide my code examples if you want,
I'm just a bit reluctant to post them here.

Bye, Thomas.


Re: Karaf feature how-to?

Posted by Thomas Vandahl <tv...@apache.org>.
Hi Jean-Baptiste,

On 05.02.17 11:52, Jean-Baptiste Onofr� wrote:
> Hi Thomas
> 
> Did you take a look on the Karaf documentation ? There is description of
> what is a feature, req/cap, ...

Do you mean like
http://karaf.apache.org/manual/latest/#_feature_and_resolver and following?

Yes, of course. It says for example "When you install a feature, Apache
Karaf installs all resources described in the feature. It means that it
will automatically resolves and installs all bundles, configurations,
and dependency features described in the feature"

Reading this makes me think that the list of Maven dependencies
(including transitive ones) should be sufficient to resolve everything.
Is this a valid assumption to make? The karaf-maven-plugin gives me for
example

<bundle>mvn:org.apache.camel/camel-blueprint/2.18.1</bundle>

Is this identical to

<feature version="2.18.1">camel-blueprint</feature>

and if not, how do I get the plugin to generate the latter from a
dependency entry in the POM? Is this possible at all or do I need to
manage the feature dependencies manually?

I just want to understand how it is meant to be.
Bye, Thomas

Re: Karaf feature how-to?

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Thomas

Did you take a look on the Karaf documentation ? There is description of what is a feature, req/cap, ...

Regards
JB

On Feb 5, 2017, 05:53, at 05:53, Thomas Vandahl <tv...@apache.org> wrote:
>Hi folks,
>
>I'm a newbie in the OSGi area, so please excuse if I ask silly
>questions. However, even intensive googling did not help.
>
>We've created an application that consists of eight bundles based on
>Camel, CXF and Blueprint. We could run it in Karaf 4.0.7 just fine when
>all dependency features/bundles were installed manually.
>
>The obvious idea was to combine all bundles and their dependencies in a
>Karaf-feature for automatic installation. From reading the docs, I
>thought that having my bundles as dependencies of the feature artifact
>would do the trick. The feature file looked promising but Karaf could
>not resolve several packages, nor could I get the feature to
>karaf:verify successfully.
>
>What else did I try:
>- building the feature file by hand as an exact copy of what had been
>done manually at the Karaf console -> no success (the usual suspects
>you
>find when searching the internet: missing blueprint container, spring
>beans, jaxb AnnotationReader, aop alliance Advice etc)
>- reducing the complexity to just one basic bundle -> no success
>- defining boot-features and prerequisites as mentioned in some
>postings
>-> no success
>- adding required features as Maven dependencies -> no success
>- copy the structure of existing feature files -> no success
>- build a KAR instead of a feature -> no success
>
>Did I even get the whole idea right? Could you please point me to a
>tutorial-kind-of-thing that explains step by step how a feature
>artifact
>is supposed to work? Or to some help with debugging?
>
>Thanks in advance for any hint you can give.
>Bye, Thomas