Why can’t JAXB find my jaxb.index when running inside Apache Felix?

OK, this took quite some digging, but the answer is not that surprising and not even that complicated: JAXB can’t find jaxb.index, because by default, newInstance(String) uses the current thread’s class loader (as returned by Thread.getContextClassLoader()). This doesn’t work inside Felix, because the OSGi bundles and the framework’s threads have separate class loaders. The solution … Read more

What exactly is Apache Karaf?

TLDR: Apache Karaf is much more ‘batteries-included’. It can also run on any OSGI runtime. Apache Felix (which is an implementation of the OSGi 4.2 framework) Sort of. Apache Karaf can use Apache Felix. Apache Karaf can also use Equinox or another OSGi runtime. By default, the Apache Karaf standard download does come with Apache … Read more

OSGi: What are the differences between Apache Felix and Apache Karaf?

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 … Read more

Reading my own Jar’s Manifest

You can do one of two things: Call getResources() and iterate through the returned collection of URLs, reading them as manifests until you find yours: Enumeration<URL> resources = getClass().getClassLoader() .getResources(“META-INF/MANIFEST.MF”); while (resources.hasMoreElements()) { try { Manifest manifest = new Manifest(resources.nextElement().openStream()); // check that this is your manifest and do what you need or get the … Read more