javadebuggingosgikaraf

How I can debug an external OSGI bundle?


I'm want to debug an external OSGI bundle to get to know how interacts with the rest of the other bundles, but I don't know how to do this.

The main program works with Karaf and OSGI, I can debug it attaching the Netbeans debugger without problems. The problem comes when I'm trying the debug an external bundle.

The external bundles are jar files that are put in the deploy/ folder of the program, then, the new bundles are installed. Karaf shows me that are installed. Also I can use those bundles as an user.

I have access to the source code of the main program and the bundle I want to debug also.

My goal is to debug this bundle to find out how interacts with the other bundles, specially what events trigger when have to write in the database.


Solution

  • Note:Following remote debugging configuration has been used for eclipse. Find the corresponding for netbeans.

    If your bundles are in deploy folder then you just need to start the karaf in debug mode by appending debug in the command at the time of starting karaf service

    bin/karaf debug
    

    It will listen for the external program to connect to it on default port which is 5005.

    Debugging in Karaf

    -Then you need to go the eclipse -> run -> debug configuration - >Remote java application.

    In the connect tab fill the following information:

    Project: Name of project

    Host:Your host( localhost in case if your system is host)

    Port:5005

    In source tab add the project files in the context of this debug configuration.

    Apply and debug. Your break points will start working.

    And if you want to debug just jar remotely. Follow the same above configuration for eclipse(excluding the karaf debug) and get the help from this answer

    https://stackoverflow.com/a/975342/3705777