You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by "John D. Ament" <jo...@gmail.com> on 2013/11/17 16:37:26 UTC

Creating custom karaf distributions

HI all,

I'm using ServiceMix 4.5.3, which uses Karaf 2.2.11.

I'm essentially trying to start from a base karaf installation, and install
on top of it the custom bundles from ServiceMix + bundles my application
needs, so that the end result is a tar.gz with all of that preconfigured
and nothing else needed but to start up.

I'm able to get the packaging fine.  I followed the instructions here:
http://karaf.apache.org/manual/latest-2.2.x/developers-guide/custom-distribution.html

For all of the base stuff, prebuilt features, the install works fine.  I
see those getting installed at start up.

I then attempted to generate a features.xml for my bundle (right now I just
have a single JAR).  This seems to not go well.  The generated
features.xml, from feedback from others is wrong.  Here's a gist of the
features.xml and the error: https://gist.github.com/johnament/7466114

A few things I've noticed.

1. even though many JARs are listed, my JAR file is not listed.  Is this
expected?
2. The biggest error seems to be that it generated a features 1.2 XML file.
 I'm told this is wrong.  I generated this XML file using this plugin
config:

    <plugin>
                <groupId>org.apache.karaf.tooling</groupId>
                <artifactId>features-maven-plugin</artifactId>
                <version>2.2.11</version>
                <executions>
                    <execution>
                        <id>generate</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>generate-features-xml</goal>
                        </goals>
                        <configuration>
                            <kernelVersion>2.2.11</kernelVersion>
                            <outputFile>target/features.xml</outputFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Which I would assume the 2.2.11 version of the plugin is compatible with
Karaf 2.2.11.

Thanks for any feedback you can give.  This is honestly my first time
dealing with Karaf & OSGi.

John

Re: Creating custom karaf distributions

Posted by Christoph Emmersberger <ce...@gmail.com>.
Hi John

sorry for the inconvenient URL postings.

I have an example for a features file here: [1] features.xml

(1) What is obvious is, that you are putting all your bundle dependencies into a single feature. This is quite unusual from my perspective.
(2) You need to make your feature visible to your application container. This can be manually conducted via:

features:addurl mvn:<path-to-your-features-file>

But it is also possible to conduct that via an entry in your ‘org.apache.karaf.features.cfg’ that you need to adjust when building your custom distribution.
(3) The created bundle may be also copied over to your $KARAF_HOME/lib directory to get resolved (in case you do not want to pull it from any maven repo.

Let me know of you have any further questions.

- Christoph


On 18 Nov 2013, at 13:36, John D. Ament <jo...@gmail.com> wrote:

> Hi Christoph
> 
> Thanks for the response.  To be honest, I'm not sure how it helps.  I
> can't open your link, I'm wondering if your line wraps are breaking
> the URL.  Do you see something wrong in my features.xml?
> 
> On Mon, Nov 18, 2013 at 3:01 AM, Christoph Emmersberger
> <ce...@gmail.com> wrote:
>> Hi John
>> 
>> I=92ve been playing in the past quite a bit with custom distributions, =
>> and own features. My current approach is:
>> 
>> (1) Proceed with the custom distribution according to [1] =
>> http://karaf.apache.org/manual/latest-2.2.x/developers-guide/custom-distri=
>> bution.html
>> (2) Write manual features.xml that is later packaged in an own bundle =
>> pulling all required dependencies. You can find an example on how this =
>> can be achieved in [2] =
>> https://git-wip-us.apache.org/repos/asf?p=3Dcamel.git;a=3Dtree;f=3Dplatfor=
>> ms/karaf/features;h=3Dc25f336d154df0d13dfd8ab8291f522f282c8652;hb=3DHEAD
>> 
>> Hope this helps,
>> 
>> Kind regards,
>> 
>> Christoph
>> 
>> On 17 Nov 2013, at 16:37, John D. Ament <jo...@gmail.com> wrote:
>> 
>> HI all,
>> 
>> I'm using ServiceMix 4.5.3, which uses Karaf 2.2.11.
>> 
>> I'm essentially trying to start from a base karaf installation, and install
>> on top of it the custom bundles from ServiceMix + bundles my application
>> needs, so that the end result is a tar.gz with all of that preconfigured and
>> nothing else needed but to start up.
>> 
>> I'm able to get the packaging fine.  I followed the instructions here:
>> http://karaf.apache.org/manual/latest-2.2.x/developers-guide/custom-distribution.html
>> 
>> For all of the base stuff, prebuilt features, the install works fine.  I see
>> those getting installed at start up.
>> 
>> I then attempted to generate a features.xml for my bundle (right now I just
>> have a single JAR).  This seems to not go well.  The generated features.xml,
>> from feedback from others is wrong.  Here's a gist of the features.xml and
>> the error: https://gist.github.com/johnament/7466114
>> 
>> A few things I've noticed.
>> 
>> 1. even though many JARs are listed, my JAR file is not listed.  Is this
>> expected?
>> 2. The biggest error seems to be that it generated a features 1.2 XML file.
>> I'm told this is wrong.  I generated this XML file using this plugin config:
>> 
>>   <plugin>
>>                <groupId>org.apache.karaf.tooling</groupId>
>>                <artifactId>features-maven-plugin</artifactId>
>>                <version>2.2.11</version>
>>                <executions>
>>                    <execution>
>>                        <id>generate</id>
>>                        <phase>generate-resources</phase>
>>                        <goals>
>>                            <goal>generate-features-xml</goal>
>>                        </goals>
>>                        <configuration>
>>                            <kernelVersion>2.2.11</kernelVersion>
>>                            <outputFile>target/features.xml</outputFile>
>>                        </configuration>
>>                    </execution>
>>                </executions>
>>            </plugin>
>> 
>> Which I would assume the 2.2.11 version of the plugin is compatible with
>> Karaf 2.2.11.
>> 
>> Thanks for any feedback you can give.  This is honestly my first time
>> dealing with Karaf & OSGi.
>> 
>> John
>> 
>> 


Re: Creating custom karaf distributions

Posted by "John D. Ament" <jo...@gmail.com>.
Hi Christoph

Thanks for the response.  To be honest, I'm not sure how it helps.  I
can't open your link, I'm wondering if your line wraps are breaking
the URL.  Do you see something wrong in my features.xml?

On Mon, Nov 18, 2013 at 3:01 AM, Christoph Emmersberger
<ce...@gmail.com> wrote:
> Hi John
>
> I=92ve been playing in the past quite a bit with custom distributions, =
> and own features. My current approach is:
>
> (1) Proceed with the custom distribution according to [1] =
> http://karaf.apache.org/manual/latest-2.2.x/developers-guide/custom-distri=
> bution.html
> (2) Write manual features.xml that is later packaged in an own bundle =
> pulling all required dependencies. You can find an example on how this =
> can be achieved in [2] =
> https://git-wip-us.apache.org/repos/asf?p=3Dcamel.git;a=3Dtree;f=3Dplatfor=
> ms/karaf/features;h=3Dc25f336d154df0d13dfd8ab8291f522f282c8652;hb=3DHEAD
>
> Hope this helps,
>
> Kind regards,
>
> Christoph
>
> On 17 Nov 2013, at 16:37, John D. Ament <jo...@gmail.com> wrote:
>
> HI all,
>
> I'm using ServiceMix 4.5.3, which uses Karaf 2.2.11.
>
> I'm essentially trying to start from a base karaf installation, and install
> on top of it the custom bundles from ServiceMix + bundles my application
> needs, so that the end result is a tar.gz with all of that preconfigured and
> nothing else needed but to start up.
>
> I'm able to get the packaging fine.  I followed the instructions here:
> http://karaf.apache.org/manual/latest-2.2.x/developers-guide/custom-distribution.html
>
> For all of the base stuff, prebuilt features, the install works fine.  I see
> those getting installed at start up.
>
> I then attempted to generate a features.xml for my bundle (right now I just
> have a single JAR).  This seems to not go well.  The generated features.xml,
> from feedback from others is wrong.  Here's a gist of the features.xml and
> the error: https://gist.github.com/johnament/7466114
>
> A few things I've noticed.
>
> 1. even though many JARs are listed, my JAR file is not listed.  Is this
> expected?
> 2. The biggest error seems to be that it generated a features 1.2 XML file.
> I'm told this is wrong.  I generated this XML file using this plugin config:
>
>    <plugin>
>                 <groupId>org.apache.karaf.tooling</groupId>
>                 <artifactId>features-maven-plugin</artifactId>
>                 <version>2.2.11</version>
>                 <executions>
>                     <execution>
>                         <id>generate</id>
>                         <phase>generate-resources</phase>
>                         <goals>
>                             <goal>generate-features-xml</goal>
>                         </goals>
>                         <configuration>
>                             <kernelVersion>2.2.11</kernelVersion>
>                             <outputFile>target/features.xml</outputFile>
>                         </configuration>
>                     </execution>
>                 </executions>
>             </plugin>
>
> Which I would assume the 2.2.11 version of the plugin is compatible with
> Karaf 2.2.11.
>
> Thanks for any feedback you can give.  This is honestly my first time
> dealing with Karaf & OSGi.
>
> John
>
>

Re: Creating custom karaf distributions

Posted by Christoph Emmersberger <ce...@gmail.com>.
Hi John

I=92ve been playing in the past quite a bit with custom distributions, =
and own features. My current approach is:

(1) Proceed with the custom distribution according to [1] =
http://karaf.apache.org/manual/latest-2.2.x/developers-guide/custom-distri=
bution.html
(2) Write manual features.xml that is later packaged in an own bundle =
pulling all required dependencies. You can find an example on how this =
can be achieved in [2] =
https://git-wip-us.apache.org/repos/asf?p=3Dcamel.git;a=3Dtree;f=3Dplatfor=
ms/karaf/features;h=3Dc25f336d154df0d13dfd8ab8291f522f282c8652;hb=3DHEAD

Hope this helps,

Kind regards,

Christoph

On 17 Nov 2013, at 16:37, John D. Ament <jo...@gmail.com> wrote:

> HI all,
> 
> I'm using ServiceMix 4.5.3, which uses Karaf 2.2.11.
> 
> I'm essentially trying to start from a base karaf installation, and install on top of it the custom bundles from ServiceMix + bundles my application needs, so that the end result is a tar.gz with all of that preconfigured and nothing else needed but to start up.
> 
> I'm able to get the packaging fine.  I followed the instructions here: http://karaf.apache.org/manual/latest-2.2.x/developers-guide/custom-distribution.html
> 
> For all of the base stuff, prebuilt features, the install works fine.  I see those getting installed at start up.
> 
> I then attempted to generate a features.xml for my bundle (right now I just have a single JAR).  This seems to not go well.  The generated features.xml, from feedback from others is wrong.  Here's a gist of the features.xml and the error: https://gist.github.com/johnament/7466114
> 
> A few things I've noticed.  
> 
> 1. even though many JARs are listed, my JAR file is not listed.  Is this expected?
> 2. The biggest error seems to be that it generated a features 1.2 XML file.  I'm told this is wrong.  I generated this XML file using this plugin config:
> 
> 		    <plugin>
>                 <groupId>org.apache.karaf.tooling</groupId>
>                 <artifactId>features-maven-plugin</artifactId>
>                 <version>2.2.11</version>
>                 <executions>
>                     <execution>
>                         <id>generate</id>
>                         <phase>generate-resources</phase>
>                         <goals>
>                             <goal>generate-features-xml</goal>
>                         </goals>
>                         <configuration>
>                             <kernelVersion>2.2.11</kernelVersion>
>                             <outputFile>target/features.xml</outputFile>
>                         </configuration>
>                     </execution>
>                 </executions>
>             </plugin>
> 
> Which I would assume the 2.2.11 version of the plugin is compatible with Karaf 2.2.11.
> 
> Thanks for any feedback you can give.  This is honestly my first time dealing with Karaf & OSGi.
> 
> John


Re: Creating custom karaf distributions

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

You have different ways for that.

1/ if you have an Internet connection, you don't need this step. If you 
can't download the bundles from Central (or other repositories), you 
have to populate the Karaf system folder with the bundles that you want 
to install at startup.
The system folder is a Maven repository (using the directory/file 
structure groupId/artifactId/version/artifactId-version[-classifier].type).
So, to populate this folder
- do it by hand (copy respecting the Maven structure)
- use the mvn deploy:deploy-file with URL on the system folder 
(-Durl=file:....)
- use the features-maven-plugin with the add-features-to-repo goal

2/ Once your system repo is populated, you can:
2.1/ install the bundle one by one, using the etc/startup.properties
2.2/ create a features XML (by hand or using the features-maven-plugin) 
and define the features as a featuresBoot in 
etc/org.apache.karaf.features.cfg. FYI, before Karaf 3.x, all features 
XML are written by hand in Karaf itself.

3/ Once you have your system repo and etc files updated, you can package 
your distribution.

I hope it helps.

Regards
JB

On 11/17/2013 04:37 PM, John D. Ament wrote:
> HI all,
>
> I'm using ServiceMix 4.5.3, which uses Karaf 2.2.11.
>
> I'm essentially trying to start from a base karaf installation, and
> install on top of it the custom bundles from ServiceMix + bundles my
> application needs, so that the end result is a tar.gz with all of that
> preconfigured and nothing else needed but to start up.
>
> I'm able to get the packaging fine.  I followed the instructions here:
> http://karaf.apache.org/manual/latest-2.2.x/developers-guide/custom-distribution.html
>
> For all of the base stuff, prebuilt features, the install works fine.  I
> see those getting installed at start up.
>
> I then attempted to generate a features.xml for my bundle (right now I
> just have a single JAR).  This seems to not go well.  The generated
> features.xml, from feedback from others is wrong.  Here's a gist of the
> features.xml and the error: https://gist.github.com/johnament/7466114
>
> A few things I've noticed.
>
> 1. even though many JARs are listed, my JAR file is not listed.  Is this
> expected?
> 2. The biggest error seems to be that it generated a features 1.2 XML
> file.  I'm told this is wrong.  I generated this XML file using this
> plugin config:
>
>     <plugin>
>                  <groupId>org.apache.karaf.tooling</groupId>
>                  <artifactId>features-maven-plugin</artifactId>
>                  <version>2.2.11</version>
>                  <executions>
>                      <execution>
>                          <id>generate</id>
>                          <phase>generate-resources</phase>
>                          <goals>
>                              <goal>generate-features-xml</goal>
>                          </goals>
>                          <configuration>
>                              <kernelVersion>2.2.11</kernelVersion>
>                              <outputFile>target/features.xml</outputFile>
>                          </configuration>
>                      </execution>
>                  </executions>
>              </plugin>
>
> Which I would assume the 2.2.11 version of the plugin is compatible with
> Karaf 2.2.11.
>
> Thanks for any feedback you can give.  This is honestly my first time
> dealing with Karaf & OSGi.
>
> John

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com