OSGi – is Fun to play, difficult to work on big projects

Today I am frustrated with OSGi Technology….Somebody got great idea….they released half cooked tools and software into market. Somebody likes the idea and simply say go and use it…without doing proper analysis. OSGi is good for project that is having very few jars (bundles) and they should available on spring source. Otherwise life is screwed up in stitching bundles and respective versions. Soon it will become great technology…it becomes like butterfly….for now it is caterpillar …looks ugly and difficult to appreciate…

If you have 100+ jars to be bundles, then you can realize the pain behind it.


TestNG for OSGi Bundles

Problem: We need to test bundles deployed in OSGi.

Solution: Bundle test classes as xyz_tests.jar file. Convert this into bundle and deploy along with main bundle code.
In test bundle activator, programmatic way call TestNG as shown in http://testng.org/doc/documentation-main.html

TestListenerAdapter tla = new TestListenerAdapter();
TestNG testng = new TestNG();
testng.setTestClasses(new Class[] { Run2.class });

TestNG opens in its own JVM. Due to this it is not recognizing test classes. We can build OSGi classpath with the help of bundle context. But we dont have option to pass classpath to TestNG programitically. Even though we can pass, it uses jar files in path, But not the bundles.

Conclusion: We can’t use TestNG inside OSGi. Please let me know your experience.


org.osgi.framework.BundleException: Cannot start a fragment bundle

Exception: While trying to start com.springsource.org.apache.xerces-2.8.1.jar bundle I got the following exception.

org.osgi.framework.BundleException: Cannot start a fragment bundle
at org.knopflerfish.framework.BundleImpl.start(BundleImpl.java:300)

Solution: We can’t start Fragment Bundle. As long as it is in resolved state, it is good. The following links can give more information about it.


Creating OSGi Bundles


Nice faq on bundles: http://www.springsource.com/repository/app/faq

Bundles repository: http://www.osgi.org/Repository/HomePage. This is giving link to spring source repository.

Spring Source bundle repository: http://www.springsource.com/repository/app/

Hibernate is part of JBoss OSGi.

Spring Hibernate Issues

There is no OSGi key word on entire Hibernate site.

Nice tutorial on how to build OSGi bundles

BND Tool. This converts given jar file to osgi bundle. It is not putting version information in it. We may need to use properties file to achieve it.

Best tutorial on wraping Hibernate into Bundle


How to do bundling?

We have two tools. One is BND and other is Bundler from spring source

http://www.aqute.biz/Code/Bnd – Now struggling with this to import version information.

http://static.springsource.org/s2-bundlor/1.0.x/user-guide/htmlsingle/user-guide.html – Need to try