Sunday, August 28, 2011

Setting up Apache Felix and installing a sample war or jar osgi bundle

Steps:
1. Download the org.apache.felix.main.distribution-3.2.2.zip file from apache-felix web site.
2. Unzip the above zip file into a folder.
3. Open a command prompt and change the directory to felix home folder.
4. Type java -jar ./bin/felix.jar

Now you will get a prompt like g!
Type lb to list the bundles
To install any OSGi-fied bundle jar/war use the below command
install file:

By default Apache felix loads the bundles which are in bundle folder.
In 3.2.2 version there are four bundles.
org.apache.felix.bundlerepository-1.6.2.jar
org.apache.felix.gogo.command-0.8.0.jar
org.apache.felix.gogo.runtime-0.8.0.jar
org.apache.felix.gogo.shell-0.8.0.jar

So whatever the bundles required to your bundle you need to install them manually or place them in the bundle folder.

For Example:
You need to install Jetty then you have to install them manually.
g!install file:./mysampleapp/web/lib/jetty-6.1.7.jar
g!install file:./mysampleapp/web/lib/jetty-util-6.1.7.jar

After installing all required bundles you need to start them by using start command and bundle id (lb command gives the bundle id)

g!start 12
here 12 is bundle id

Some times felix might not start the bundles properly so use felix:refresh or stop and start the bundles. I don't know why some times felix is not starting the bundles properly.








No comments:

Post a Comment