Search code examples
osgiapache-karafapache-felixosgi-bundle

How to get Apache karaf bundles information via web services (rest, soap)?


I wonder is there any change get the information about bundles via web services (rest, soap)

I've found web console hawtio which runs on port 8181 and I see the list of bundles. And I would like to get this info in json.


Solution

  • Hawtio uses jolokia for accessing the bundle list. The jolokia project provides web applications called agents serving a REST API. For quick experiments you can deploy the war jolokia-war-unsecured into the hot deploy folder of a running karaf instance. This installs a A REST web service at e.g. http://localhost/jolokia-war-unsecured/ which does not require any authentications.

    In order to get the web application to run, the war feature is required. If it not running already you can install it via feature:install war within the karaf shell. With the web:list command you can always verify the deployed and running web applications:

    karaf@root()> web:list
    ID  | State       | Web-State   | Level | Web-ContextPath        | Name
    ----+-------------+-------------+-------+------------------------+------------------------------
    100 | Active      | Deployed    | 80    | /jolokia-war-unsecured | jolokia-war-unsecured (1.6.0)`
    

    With jolokia you can access any MBean of the Karaf JVM. To list the bundles the URL is for instance:

    http://localhost:8181/jolokia-war-unsecured/read/org.apache.karaf:type=bundles,name=root/