This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • DOSGi Discovery

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

This page outlines setting up the Discovery implementation that is part of CXF Distributed OSGi.


The Distributed OSGi document RFC 119 also describes a standard way publish and obtain remote service metadata. A primary use-cases for this is a Discovery system. How the discovery system works is not described, but the interaction with the Discovery system is. This interaction happens through OSGi services.

The CXF/DOSGi project comes with a RFC 119 compliant Discovery implementation that uses Apache ZooKeeper as the underlying technology for the Discovery Server. This page outlines how to get started with CXF DOSGi/Discovery.

Installing and run the ZooKeeper server

Read the ZooKeeper Getting Started page:

The ZooKeeper distribution doesn't contain any Windows scripts yet. If you're on Windows you can download scripts to start the ZooKeeper server and the client program from here.

Once you have ZooKeeper installed (the current version used is 3.2.1), run its server:

Code Block
$ bin/zkServer
... log messages ...
2009-06-10 13:23:27,288 - INFO  [main:FileTxnSnapLog@198] - Snapshotting: 0

The ZooKeeper server is now ready.

You can check that all is well by running the client program:

Code Block
$ bin/zkCli -server localhost:2181
--> ls /
Processing ls

So besides the zookeeper node, there is nothing in the ZooKeeper virtual filesystem yet.

Installing the CXF Discovery Bundles

The CXF/DOSGi Discovery implementation interacts with the ZooKeeper server. It's included in both the Single-bundle and Multi-bundle distributions of CXF-DOSGi.

Single Bundle Distribution

When you are using the CXF-DOSGi Single-Bundle distro, you automatically get the Discovery functionality with that.

Code Block
-> install
Bundle ID: 4
-> install
Bundle ID: 5
-> start 5
... log messages ...
-> ps
   ID   State         Level  Name
[   0] [Active     ] [    0] System Bundle (1.8.0)
[   1] [Active     ] [    1] Apache Felix Shell Service (1.2.0)
[   2] [Active     ] [    1] Apache Felix Shell TUI (1.2.0)
[   3] [Active     ] [    1] Apache Felix Bundle Repository (1.4.0)
[   4] [Resolved   ] [    1] osgi.cmpn (
[   5] [Active     ] [    1] Distributed OSGi Distribution Software Single-Bundle Distribution (1.1)

The Discovery bundle is now active, but it doesn't do anything yet since it's not yet configured.

Multi Bundle Distribution


Configuring Discovery

The CXF/Discovery component is configured through the OSGi Configuration Admin Service. For convenience the CXF/Discovery distributions come with the Configuration Admin and FileInstall implementations from Felix, but you can also use another implementation of the Configuration Admin service.

When you start up the bundle(s) in the CXF/Discovery distribution, the FileInstall bundle will create a 'load' directory in the current working directory. This is where you can put Config Admin configurations.

To configure the ZooKeeper client in CXF/Discovery the following configuration variables apply. They need to be set on Configuration Admin PID org.apache.cxf.dosgi.discovery.zookeeper.

Configuration property



no default

The host where the ZooKeeper server is running.



The port of the ZooKeeper server.



Sets the ZooKeeper tick time.

For more information on the ZooKeeper configuration variables see the ZooKeeper administration guide:

An easy way to set the configuration, it by placing a file called org.apache.cxf.dosgi.discovery.zookeeper.cfg in the load directory created by the FileInstall bundle with the following content:

Code Block =

As soon as you set the configuration, the Discovery will connect to the ZooKeeper server. You will see a few log messages on the ZooKeeper server console to reflect this.

You can always check the configuration of the ZooKeeper client by looking at the ManagedService registered by the CXF/Discovery bundle:

Code Block
-> services 5

Distributed OSGi Zookeeper-Based Discovery Single-Bundle Distribution (6) provides:
... other services ...
objectClass =
felix.fileinstall.filename = org.apache.cxf.dosgi.discovery.zookeeper.cfg = 38 = org.apache.cxf.dosgi.discovery.zookeeper = localhost
zookeeper.port = 2181
zookeeper.timeout = 3000

For further information and a walkthrough of the Discovery demo see the DOSGi Discovery Demo page.