143

Apache Karaf is a sub project of Apache Felix. It is defined as "a lightweight OSGi container".

I don't understand when should I use the heavyweight and when to use the lightweight. Their site doesn't explain this too much.

3 Answers 3

218

The 'lightweight OSGi container' label is contrasting Karaf with more feature rich OSGi containers, not with Felix.

To quote Guillaume Nodet (Karaf's author) from here:

Felix is just the OSGi core runtime. Karaf provides a "distribution" based on Felix by adding other features such as a console, an SSH remoting mechanism, a file deployer and more.

In this diagram of the Karaf architecture, Felix (or other OSGi implementation - currently Equinox is also supported) is the OSGi box, the other boxes are the features added by Karaf:

Karaf Architecture Therefore, unless you have specific needs which are not met by Karaf (requiring access to the underlying implementation) it usually makes sense to use this since it provides more 'out of the box'.

3
  • 7
    One nice feature of any OSGi container is that you can select just the bundles you need and deploy them into your container. So my advice would be to first architect your application, and then pick what you need. The advice to "just install the whole platform because it is feature rich" sounds a bit like going back to the huge Java EE application servers. Now I'm not saying that Apache Karaf is anywhere near as big as those, I am just making a point that you can and should just deploy what you actually need. Sep 19, 2014 at 6:17
  • 2
    It seems to me this answer is incomplete in that it doesn't mention the use case of embedding Felix in an application (without the need for using a container such as Karaf) - for example to provide plugin capability - which is my interpretation of the following link. Am I wrong? (I'm no expert.) Link: felix.apache.org/documentation/subprojects/…
    – Woodchuck
    May 1, 2017 at 20:14
  • does Karaf use Felix or Equinox by default? thanks Jul 12, 2022 at 23:19
8

@Marcel Karaf isn't monolithic or huge like a Java EE server. It is a very slim and minimalist implementation. It is a core product without much functionality other than a basic console, file loading so that you can actually read configuration files, etc. The latest zip file of it is 19.1 MB. Yeah. Small. It can easily run on small devices and work in embedded.

What you may be thinking of is something more like ServiceMix which uses Karaf as a core/kernel. But it includes CXF, ActiveMQ, Camel and other libraries in its full configuration. Even then they have minimal, medium and full sizes.

Really, for 99% of the projects out there it wouldn't make sense to start directly with Felix and not use Karaf instead.

0

Currently, there are three popular open source OSGi containers:

  - Equinox. It is the modular Java runtime at the heart of the Eclipse IDE,
  - Knopflerfish, Is an open source implementation of the OSGi R3 and OSGi R4 specifications. 
  - Apache Felix. Is the open source OSGi container from the Apache Software Foundation.

http://www.javaworld.com/article/2077837/java-se/java-se-hello-osgi-part-1-bundles-for-beginners.html

The Apache project maintains a general-purpose OSGi container called Felix. Here is used as ServiceMix and

The main difference between the ServiceMix and Karaf is that ServiceMix bundles a bunch of other integration components — ActiveMQ message broker, the Camel routing engine, and some other things

According: http://kevinboone.net/osgitest.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.