Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to debug OSGI bundles in Karaf

To date, I've been successful at building OSGI bundles, and invoking web services defined in these bundles via Apache CXF. Next, I'd like to be able to set breakpoints in my bundles as they are executed within the Karaf environment.

I've looked into EIK, but it doesn't seem that project has been active in a while? And the compatibility page indicates the latest Eclipse version for which it is compatible is Juno.

I've also come across the following quote on StackOverflow from when the EIK project seemed to be last active:

The Karaf team is now also working on a better integration with EIK, but at the current time it's not yet as deeply integrated as it would be needed (see the related issue)

What is the best way to debug OSGI bundles running in Karaf 3.0.3 or Karaf 4.0.0 M3 using Eclipse?

like image 265
Randy Leonard Avatar asked Jun 09 '15 15:06

Randy Leonard


People also ask

How do I debug in Karaf?

Usually, the easiest way to debug Karaf or any application deployed onto it is to use remote debugging. Remote debugging can be easily activated by using the debug parameter on the command line. Another option is to set the KARAF_DEBUG environment variable to TRUE.

How do I debug OSGi bundle in Eclipse?

To run your bundles, right click and choose Run as ->OSGi Framework (or debug as). You can tweak which bundles are included in the runtime configuration, and what arguments are used. You may for example want to add -console . You can also create an application for export, which will give you a config.

How do you deploy bundles in Karaf?

To add it to the deploy directory run mvn clean package from the root folder of your project (Where the pom. xml resides). This will generate a jar file in the target folder. Drag and drop it to the deploy from there.


1 Answers

The best way for me is to use the debug option when launching Karaf. This allows you to perform remote debugging ( I have done it from Eclipse and Intelli J with no problems). Just make sure your source is up to date with the karaf instance you are running. See this for more info:

  • Karaf 3 manual - debugging
  • Karaf 4 manual - debugging
like image 120
Jorge Martinez Avatar answered Sep 28 '22 01:09

Jorge Martinez