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.








Saturday, August 27, 2011

If you are getting generics are not supported in -source 1.3 in maven

When you execute maven clean install if you are getting "generics not supported in -source 1.3" then add the below plugin into the pom.xml then execute the maven eclipse:eclipse then refresh your project in eclipse.
<plugin>
<groupid>org.apache.maven.plugins</groupid>
<artifactid>maven-compile-plugin</artifactid>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>

Thursday, August 18, 2011

Useful commands of karaf OSGI server console

Installing an OSGi bundle from your local file system or local repository. Type the below command on the karaf console.
karaf@root> osgi:install -s file:C:/myrepo/org/apache/camel/camel-osgi/1.5.0/camel-osgi-1.5.0.jar
List OSGi bundles
karaf@root> osgi:list
Search for a specific or gorup of osgi bundle. Below example lists all camel osgi bundles
karaf@root> osgi:list grep camel
Stopping an OSGi bundle
karaf@root> osgi:stop bundle id

Installing featues in servicemix or karaf OSGI server:
First add the url of the feature but make sure that this feature is already installed in your maven repository otherwise you will not be able to install.
karaf@root> featues:addUrl -s mvn:org.apache.camel.karaf/apache-camel/2.7.1/xml/features
-s option starts all features listed in the descriptor file.
karaf@root> features:install camel-http
To list all features installed in servicemix or karaf
karaf@root> features:list
karaf@root> features:list grep feature name