Jump to: navigation, search

CrossProject:Integration Group:karaf

Karaf Hints and Tips

This page is just to list some helpful hints and tips.

Suggestions Before Starting

In case you are redeploying a karaf distro (i.e. with different features) remove the data folder:

rm -rf karaf-distro/data/*

With master code you have to also remove cluster data:

rm -rf karaf-distro/snapshots/*
rm -rf karaf-distro/journal/*

Default Java options for Karaf are: -Xmx2048m -XX:MaxPermSize=512m

In case you need more:

export JAVA_OPTS="-Xmx4096m -XX:MaxPermSize=512m"

Starting Karaf

There two way's to start the controller


This will drop you direct into Karaf console.


This will start karaf as a background task, can access the console via bin/client or SSH


This will connect to the Karaf console from the linux shell

bin/client <command>

This will execute a command on the Karaf console and return to linux shell

Getting your code into Karaf (for developers; -DaddInstallRepositoryPath / addInstallRepositoryPath)

Karaf loads the JAR files containing your code from the local private Maven repository in its system/ directory, which is specific to each Karaf (and NOT the your system-wide ~/.m2/repository). Therefore if you mvn install an artifact globally, it will not be picked up by your Karaf. Instead of always rebuilding your entire Karaf distro, or manually copying built JARs to the right place, use this to install your Karaf's system/ repo (additionally to ~/.m2/repository, not instead of):

   mvn -o -Pq -DaddInstallRepositoryPath=$KARAF_HOME/system install

After doing the above, you'll have to stop karaf, remove the $KARAF_HOME/data directory, and then start karaf anew. You can also let Karaf "watch" hot for new bundles to automatically reload them on the fly, by typing this command into the Karaf console:

  bundle:watch *

This works for bundles based on ODL Config (CSS), but is broken for Blueprint (BP) based bundles due to ClassLoader issues in BP on bundle reload.


There been some port changes that AD-SAL and MD-SAL API's

RESTCONF = 8181 (Yang, Dlux, MD-SAL API's)
REST = 8080 (AD-SAL API)


We can use SSH to access the Karaf console, kind of like how we had telnet to access OSGi console

SSH is listening on 8101 and default username/password is karaf/karaf

I recommend the command below as the HostKey isn't kept and we don't check the host key.

ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 8101 karaf@<controllerIP>

Log out of the ssh shell


Configure features at startup (Optional)

Features can be installed automatically when karaf starts by editing features file:

vi karaf-distro/etc/org.apache.karaf.features.cfg 

modify this line:


to be:


Karaf CLI

To list only installed features

 feature:list -i 

Filter with grep

 feature:list | grep openflowplugin 

list bundles loaded

 bundle:list -s 

List web endpoints


Install a feature

 feature:install odl-l2switch-switch 

For a complete list of features and their description please check the ODL Installation Guide:


Debugging Karaf

Set root logger to ERROR:

 log:set ERROR 

Set bundle to debug to TRACE:

 log:set TRACE org.opendaylight.l2switch 

See log in karaf:


or see log outside karaf:

 tail -f karaf-distro/data/log/karaf.log 

You can find more debug information in: http://karaf.apache.org/manual/latest-2.2.x/developers-guide/debugging.html