You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Kerry <ka...@avionicengineers.com> on 2017/11/24 18:50:48 UTC
Include Karaf feature in POM dependency
Hi,
I'm trying to specify Karaf feature dependencies in my POM so that I can generate a features XML for my own bundle that will install the features as well.
How do I specify for example the pax-jdbc-mariadb feature with Maven coordinates? It's part of the enterprise feature I believe but I don't want to install all of enterprise, so how can I install individual features?
thanks, Kerry
Re: Include Karaf feature in POM dependency
Posted by Kerry <ka...@avionicengineers.com>.
On 30/11/17 17:00, Steinar Bang wrote:
>>>>>> Kerry <ka...@avionicengineers.com>:
>> Yes that is what I meant, I have to use a template to create a
>> features.xml. I've looked at the code for GenerateDescriptorMojo and
>> searched the Karaf source for an example of what I need but couldn't
>> find anything.
> I've created a feature request for this: https://issues.apache.org/jira/browse/KARAF-5512
>
>> Using the template technique I've also discovered that when I deployed
>> my feature it can fail. For example if I have 3 of my bundles A, B and
>> C in the feature such that:
>> B depends on a service from C and A depends on B
>> deployment can fail due to a required service from C not being
>> available 'in-time' for B - I think that's what happening. If I deploy
>> the bundles individually everything works. I'll try playing around
>> with it but this is obviously nothing to do with the
>> GenerateDescriptorMojo.
> Hm... B should be robust enough to handle services arriving at any time
> and in any order.
>
> But if bundle B is outside of your control, then maybe you could force
> the correct load order in some way...? Maybe a hiearchy of feature
> dependencies would do the trick?
>
> Ie. make a feature for C that loads C. Then make a feature for B that
> loads bundle B and requires feature C. Then make a feature for A that
> loads bundle A and requires feature B.
>
> Then make your feature be dependent on feature A.
>
> Something like that...?
>
>
Hi Steinar,
Sorry taken me a while to get back to you.
1. thanks for raising up the JIRA ticket I also would like to keep my features specification within the POM if possible.
2. Regarding the resolving of bundles in a feature, I don't believe that it's because the bundles are not robust, it's more like the feature deployer within Karaf isn't flexible enough to allow services to become available that are provided within the same feature. I have created an example here : https://github.com/jtkb/jpatest/blob/feature/karaf_features/simple-datasource/src/main/feature/feature.xml
If I try to deploy this feature I get the deployment error:
resolution:=mandatory [caused by: Unable to resolve com.javatechnics.jpa.simple/1.0.0.SNAPSHOT: missing requirement [com.javatechnics.jpa.simple/1.0.0.SNAPSHOT] osgi.service; objectClass=javax.persistence.spi.PersistenceProvider; javax.persistence.provider=org.apache.openjpa.persistence.PersistenceProviderImpl; effective:=active]]
Remove the last bundle from the features.xml ('simple'), deploy the feature and THEN install the 'simple' bundle manually it all works fine. Unless I am configuring my feature incorrectly there doesn't seem to be a way of including DAO/persistence unit bundle AND the datasource bundle within the same feature.
Kerry
Re: Include Karaf feature in POM dependency
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Kerry <ka...@avionicengineers.com>:
> Yes that is what I meant, I have to use a template to create a
> features.xml. I've looked at the code for GenerateDescriptorMojo and
> searched the Karaf source for an example of what I need but couldn't
> find anything.
I've created a feature request for this: https://issues.apache.org/jira/browse/KARAF-5512
> Using the template technique I've also discovered that when I deployed
> my feature it can fail. For example if I have 3 of my bundles A, B and
> C in the feature such that:
> B depends on a service from C and A depends on B
> deployment can fail due to a required service from C not being
> available 'in-time' for B - I think that's what happening. If I deploy
> the bundles individually everything works. I'll try playing around
> with it but this is obviously nothing to do with the
> GenerateDescriptorMojo.
Hm... B should be robust enough to handle services arriving at any time
and in any order.
But if bundle B is outside of your control, then maybe you could force
the correct load order in some way...? Maybe a hiearchy of feature
dependencies would do the trick?
Ie. make a feature for C that loads C. Then make a feature for B that
loads bundle B and requires feature C. Then make a feature for A that
loads bundle A and requires feature B.
Then make your feature be dependent on feature A.
Something like that...?
Re: Include Karaf feature in POM dependency
Posted by Kerry <ka...@avionicengineers.com>.
On 26/11/17 07:47, Steinar Bang wrote:
>>>>>> Jean-Baptiste Onofré <jb...@nanthrax.net>:
>> The generate-descriptor MOJO (or if you use the feature packaging)
>> will create a feature.xml.
> Yes.
>
> But what he was saying, was that the generate-descriptor doesn't use
> <features>
> <feature>somefeature</feature>
> </features>
> from the karaf-maven-plugin <configuration> as dependencies.
>
> It only uses those dependencies found in a template.xml.
>
> And since I prefer to have all of the config in the POM instead of some
> in the POM and some in a different place, I thought that was a good
> idea.
>
> The OP offered to make a PR for the change.
>
>
> - Steinar
>
Steinar,
Yes that is what I meant, I have to use a template to create a features.xml. I've looked at the code for GenerateDescriptorMojo and searched the Karaf source for an example of what I need but couldn't find anything.
Using the template technique I've also discovered that when I deployed my feature it can fail. For example if I have 3 of my bundles A, B and C in the feature such that:
B depends on a service from C and A depends on B
deployment can fail due to a required service from C not being available 'in-time' for B - I think that's what happening. If I deploy the bundles individually everything works. I'll try playing around with it but this is obviously nothing to do with the GenerateDescriptorMojo.
Kerry
Re: Include Karaf feature in POM dependency
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Jean-Baptiste Onofré <jb...@nanthrax.net>:
> The generate-descriptor MOJO (or if you use the feature packaging)
> will create a feature.xml.
Yes.
But what he was saying, was that the generate-descriptor doesn't use
<features>
<feature>somefeature</feature>
</features>
from the karaf-maven-plugin <configuration> as dependencies.
It only uses those dependencies found in a template.xml.
And since I prefer to have all of the config in the POM instead of some
in the POM and some in a different place, I thought that was a good
idea.
The OP offered to make a PR for the change.
- Steinar
Re: Include Karaf feature in POM dependency
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
The generate-descriptor MOJO (or if you use the feature packaging) will create a
feature.xml.
It's what we are using internally in Karaf.
Regards
JB
On 11/25/2017 11:00 AM, Kerry wrote:
> Thanks JB.
>
> I have a feeling I've asked this already but I think the plug-in options are
> aimed at building a KAR? I just want to create a features file with the included
> feature dependencies. I think the only way to do this is to provide a template
> features XML file?
>
> I was going to see if I can tweak the karaf-maven-plugin to do as I want. Would
> this be of interest as a possible PR?
>
> Kerry
>
>
> On 24/11/17 19:43, Jean-Baptiste Onofré wrote:
>> Hi,
>>
>> The karaf-maven-plugin support <feature/> tag.
>>
>> Regards
>> JB
>>
>> On 11/24/2017 07:50 PM, Kerry wrote:
>>> Hi,
>>>
>>> I'm trying to specify Karaf feature dependencies in my POM so that I can
>>> generate a features XML for my own bundle that will install the features as
>>> well.
>>>
>>> How do I specify for example the pax-jdbc-mariadb feature with Maven
>>> coordinates? It's part of the enterprise feature I believe but I don't want
>>> to install all of enterprise, so how can I install individual features?
>>>
>>> thanks, Kerry
>>>
>>
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: Include Karaf feature in POM dependency
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Kerry <ka...@avionicengineers.com>:
> I have a feeling I've asked this already but I think the plug-in
> options are aimed at building a KAR? I just want to create a features
> file with the included feature dependencies. I think the only way to
> do this is to provide a template features XML file?
I tried just now, and it looks like you're right.
I took this config, which creates a feature file attachment to a bundle
maven artifact
https://github.com/steinarb/post-body-capture/blob/master/pom.xml#L189
and added the following to the <configuration>:
<features>
<features>pax-http-whiteboard</features>
</features>
Then I bumped the karaf version from 4.1.2 to 4.1.3 (to be sure I had
the newest Java 8 compatible version).
And then I removed the template feature.xml:
https://github.com/steinarb/post-body-capture/blob/master/src/main/feature/feature.xml
Then I tried a "mvn clean install".
The generated target/feature/feature.xml file does not have
pax-http-whiteboard as a feature dependency:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="post-body-capture">
<feature name="post-body-capture" description="Servlet dumping POSTed data to files" version="1.0.0.SNAPSHOT">
<bundle start-level="80">mvn:no.priv.bang.debug-utils/post-body-capture/1.0.0-SNAPSHOT</bundle>
</feature>
</features>
> I was going to see if I can tweak the karaf-maven-plugin to do as I
> want. Would this be of interest as a possible PR?
I would be interested in using this, er..., feature at least..:-)
(bye-bye to the template feature.xml files)
(Perhaps a Jira issue should be created before submitting the PR?)
Re: Include Karaf feature in POM dependency
Posted by Kerry <ka...@avionicengineers.com>.
Thanks JB.
I have a feeling I've asked this already but I think the plug-in options are aimed at building a KAR? I just want to create a features file with the included feature dependencies. I think the only way to do this is to provide a template features XML file?
I was going to see if I can tweak the karaf-maven-plugin to do as I want. Would this be of interest as a possible PR?
Kerry
On 24/11/17 19:43, Jean-Baptiste Onofré wrote:
> Hi,
>
> The karaf-maven-plugin support <feature/> tag.
>
> Regards
> JB
>
> On 11/24/2017 07:50 PM, Kerry wrote:
>> Hi,
>>
>> I'm trying to specify Karaf feature dependencies in my POM so that I can generate a features XML for my own bundle that will install the features as well.
>>
>> How do I specify for example the pax-jdbc-mariadb feature with Maven coordinates? It's part of the enterprise feature I believe but I don't want to install all of enterprise, so how can I install individual features?
>>
>> thanks, Kerry
>>
>
Re: Include Karaf feature in POM dependency
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,
The karaf-maven-plugin support <feature/> tag.
Regards
JB
On 11/24/2017 07:50 PM, Kerry wrote:
> Hi,
>
> I'm trying to specify Karaf feature dependencies in my POM so that I can
> generate a features XML for my own bundle that will install the features as well.
>
> How do I specify for example the pax-jdbc-mariadb feature with Maven
> coordinates? It's part of the enterprise feature I believe but I don't want to
> install all of enterprise, so how can I install individual features?
>
> thanks, Kerry
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com