satlearner
satlearner

Reputation: 345

Identify OSGI Bundle failure in Karaf programmatically

We are using Karaf-4 as OSGI container. We have several bundles associated with a feature. When any bundle fails in a feature, we want to identify programmatically. We tried BundleTracker and BundleListener, but we are not getting notification when a bundle fails after waiting in "GracePeriod" state.

We are able to view the status of failure bundle using "list" command in karaf console. We want to achieve this programmatically through notification rather than we execute "list" command in the karaf console.

Upvotes: 2

Views: 1909

Answers (1)

Christian Schneider
Christian Schneider

Reputation: 19606

You can use the BundleService as an OSGi service. The method getInfo gives you among other the BundleState. For failed bundles you can then call getDiag to get the detailed status.

Actually this is what the diag command does internally.

Upvotes: 3

Related Questions