Two possible mistakes when using OSGi declarative services

As I have already mentioned in my previous posts, we are using OSGi declarative services in Carbon to properly handle dependencies among bundles while keeping the expected dynamism. About one week back, when I was implementing a new feature in Carbon, I had to waste few hours due to two mistakes that I had made in using declarative services. So thought of sharing it as anybody can make these mistakes in declarative services.

We are using Equinox as the OSGi implementation which runs underneath Carbon. And also we are using felix maven-bundle-plugin to create bundles and felix maven-scr-plugin in using declarative services.

Now let’s move into the most important part. Think about a scenario in which you have a bundle A which registers an OSGi service called FooService and bundle B which uses this FooService. Now you have to write a declarative service component in B which contains the set and unset methods for FooService. As you might already know, you have to have an xml file which describes this declarative service, inside the OSGI-INF folder of your bundle. maven-scr-plugin generates this file for you if you have added correct annotations on the top of your declarative service component class. And also bundle B has to import the package in A which contains the FooService.

The two mistakes that I had done in my case are as follows.

  1. In my bundle B, the class which uses the FooService was missing. As I’ve mentioned above, we are using maven-bundle-plugin to generate the MANIFEST.MF file of our bundles. Bundle plugin only includes a package in the bundle if that package is exported or private packaged in the bundle. I had not done any of these. This is a simple mistake. But it’s really hard to find. This is because, OSGi environment doesn’t give any errors or exceptions and it shows that the declarative service component is satisfied. But the logic inside it never executes. OSGi environment can see the declarative service definition as it is in the xml file inside OSGI-INF folder. But the actual class is missing in this case.
  2. Say FooService is in org.example package in A. I had imported org.example package in B. But the declarative service component in B was never getting satisfied. The reason for this was I had another bundle C which exports the org.example package and bundle B had got wired with that bundle. To solve this problem, you have to remove that package export from C or properly version the package exported from A and import the same version from B.

Even though these are small mistakes, it’s not easy to identify these issues. It can waste your time and effort. Hope this will help..

Advertisements

Latest family of WSO2 products released on Carbon 2.0!..

WSO2’s SOA platform story was extended with four new products few days back. That includes WSAS 3.1.0, ESB 2.1.0, IS 2.0.0 and G-Reg 3.0.0. All those are on Carbon platform 2.0. I think this the most stable version of Carbon which we have released so far. Therefore the stability of the products also has increased a lot.

Carbon 2.0 comes with some elegant architectural improvements compared to it’s last version 1.5.1. Latest technical tricks of OSGi have been used to make Carbon more dynamic and flexible.

  • Removal of bundle start levels through the usage of OSGi declarative services is one such step. Now we don’t specify the starting order of bundles and Carbon makes sure all are started in the proper order. This is the expected behaviour of OSGi based system. Or in other words the correct level of dynamism.
  • P2 integration in Carbon is the other major improvement which was done through OSGi techniques. Through this, a user can install the required bundles in Carbon from a P2 repository and create the Carbon instance which consists of his requirements. However the P2 support in Carbon is still young and you can expect more wonders in the future releases of Carbon.

And also I’m very happy to mention that this was a very smooth release for us as developers and we didn’t need any last minute sleepless nights :). This implies the quality of the products and the fact that they are really stable. And also we followed the correct open source release process including alphas, betas, RCs with proper branching and tagging strategies.

So if you are in need of any sort of an SOA solution or studying SOA related stuff, give it a try with WSO2’s SOA platform. You’ll find life lot easier with all the cool features of Carbon. And also, we have already started with our Carbon TODOs for the next release. So stay tuned :)..

Convocation and My Gold Medal

The general convocation of University of Moratuwa for 2009 was held on 25th of June. It was a great day in my life due to many reasons. Obviously the day of graduation is a special day for any graduand. But it was bit more special for me as I had a piece of gold :).

I was awarded the gold medal which is for the best performance (highest GPA) in the department of computer science and engineering department. It is one of the greatest achievements in my life and I’m really proud to bear it :)..

My Gold Medal I can remember two similar days in my school time at Richmond College. First one is the day I was awarded the Principal’s Medal for the best performance in G.C.E O/L examination (I was ranked 9th of the island). Second is the day I was awarded the Weerasinghe Medal for the best result in physical science in G.C.E A/L examination (I was ranked 5th in the district).

There are many people who helped me in my academic career which has become a great success. First of all I’m grateful to my parents who were behind me in every single day in my life. And also my two brothers who showed me the way right through. I always believe that the factor that they were extremely successful in their academic careers was a great catalyst for my career. Then I have to thank all my teachers from nursery to primary school (Christ Church boys’ college, Baddegama) to Richmond College to UOM. And also there have been lots of friends right from my child hood to my working place, who have helped and encouraged me immensely.

So at the end of the day, I have to say that I’m extremely happy about my academic career and proud to bear the gold medal. But I always believed and believe that there are at least few of my friends at CSE who deserve the award for “Best Performance” more than my self :). Unfortunately, the “Best Performance” was measured through the GPA. It’s true that there is no other way to measure. But I always feel like it doesn’t find the “Best Performer”. Sometimes you may feel that I’m stupid.. May be I am :D..

Finally I have to say that I’m really happy about what I’ve achieved and will try to serve my country in the best way I can in the future..