New Project: OSGi-Compatible JSR APIs Print

I guess it's now more than a dozen of times I had problems with one of the most common JSR APIs like StAX, JPA, JAXB, etc. when running them in OSGi Environments. All the problems I had were class/resource loading related problems. The problem was obvious, since the libraries for these APIs are OSGi oblivious, they were loading needed classes and resources using thread's context class loader. The solution was obvious too, before executing the API code set thread's context class loader to a class loader which loads classes and resources from the OSGi Environment - Lets skip on the fact that it's not easy for every one to find/create an OSGi Environment class loader and it's not really comfortable to write the code which sets thread's class loader each time you use the API. About a week ago I began working on an application that would allow developers to run Axis2-OSGi bundle in an OSGi Environment within few seconds. One of the problems I had while working on the application was the fact that Axis2 used Streaming API for XML (StAX). StAX-API loaded service implementation classes using thread's context loader and since I had no control over Axis2 source code to set thread's context class loader it was more like a Checkmate - An alternative solution was to make implementation's bundle (Be it StAX Reference Implementation or Woodstox) the host bundle for the StAX API bundle or make the StAX API bundle import the implementation bundles, not only that the two solutions are quite dirty for many reasons they didn't work when the application was run in Apache Felix too.

Having the problem above, I realized that developing an OSGi-compatible version of StAX API not only will solve the problem above but will also simplify the usage of StAX API from OSGi Environments significantly since developers will not have to face class loading and other related problems each time they use StAX API in an OSGi Environment. This case gave me the initiative to work on the new project: OSGi-Compatible JSR APIs. I began the project with an implementation of OSGi-compatible version of the StAX API and currently working on similar versions for JPA and JAXB.

I recommend anyone who uses JSR APIs in their OSGi-based applications to check the project, since there is a probability that it will save you hours of work.