Karaf Archives (KAR)

Karaf provides a specific archive format named the KAR (Karaf ARchive).

Basically, the kar format is a jar (so a zip file) which contains a set of feature descriptor and bundle jar files.

For instance, a kar looks like:

  • my-features-1.xml
  • bundle1.jar
  • bundle2.jar
  • bundle3.jar

all packaged in zip format.

Create a kar archive

You can create a kar file by hand, just by zip compressing a directory representing the kar content.

You can also use the Karaf features maven plugin. The features maven plugin provides an create-kar goal.

The kar-archive goal:
1. Reads all features specified in the features descriptor.
2. For each feature, it resolves the bundles defined in the feature.
3. All bundles are packaged into the kar archive.

For instance, you can use the following POM to create a kar:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">





For the example, the features descriptor is very simple:

<?xml version="1.0" encoding="UTF-8"?>

   <feature name="my" version="1.0">


To create the kar archive, simply type:

mvn install

and you will have your kar in the target directory.

Deploy a kar archive

Karaf provides a KAR deployer:

karaf@root> la|grep -i archive
[  12] [Active     ] [Created     ] [   30] Apache Karaf :: Deployer :: Karaf Archive (.kar) (2.2.4)

It's a core deployer (you don't need to install additional features).

To deploy a kar, simply drop the kar into the deploy directory. The KAR Deployer will deploy all the kar content starting
from the features descriptor.

The KAR Deployer uncompress KAR archives in the system repository and register the features descriptor.
All features contained in a KAR archive will be automatically installed at deployment time.
You can now see your features installed:

karaf@root> features:list|grep -i my
[  installed] [1.0             ] my                            repo-0