Home > OSGi > OSGi debugging

OSGi debugging

November 28, 2008 Leave a comment Go to comments

OSGi debugging can turn out to be a nightmare at times, especially when using OSGi declarative services. The steps below might provide some solace.

1. Using diag OSGi command

The OSGi console is automatically enabled if you launch your bundle from eclipse launch configuration as a “OSGi Framework”. Else you could add the argument -console to your launch configuration. This will enable the OSGi console upon run.

There are lot of OSGi commands that can be used from the console. You could get the list by simply typing help at the console.

To diagnose a particular bundle, type ss at the console to see its status. This would give you a list like, for example:

osgi> ss

Framework is launched.

id State Bundle
0 ACTIVE org.eclipse.osgi_3.4.0.v20080605-1900
1 ACTIVE org.eclipse.osgi.services_3.1.200.v20071203
2 ACTIVE org.eclipse.equinox.ds_1.0.0.v20080427-0830
3 ACTIVE org.my.bundle._1.0.0
4 ACTIVE org.his.bundle_1.0.0
5 ACTIVE org.her.bundle_1.0.0
6 ACTIVE org.eclipse.equinox.util_1.0.0.v20080414

Use the command diag to diagnose a particular bundle.

For instance,

osgi> diag 3

initial@reference:file:plugins/org.my.bundle._1.0.0.jar/ [1]
Direct constraints which are unresolved:
Missing imported package org.someones.bundle_0.0.0.

3 is the id of the bundle org.my.bundle._1.0.0 above

2. Using -Dequinox.ds.print=true

Using VM argument -Dequinox.ds.print=true in your Launch configuration will echo all error messages to your console.

3. Using OSGi logging service

Start the OSGI bundle org.eclipse.equinox.log. With this bundle enabled, you could use the command log in your OSGi console.

For example,

osgi> log

>Info [2] Log created; Log Size=100; Log Threshold=4 initial@reference:file:plugins/org.eclipse.equinox.log_1.1.0.v20080414.jar/
>Info [2] ServiceEvent REGISTERED {service.id=23}
>Info [2] ServiceEvent REGISTERED {service.id=24}
>Info [2] ServiceEvent REGISTERED {service.id=25}

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: