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.

Advertisements

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.addListener(tla);
testng.run();

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.

-o-

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.
http://www.osgi.org/javadoc/r4v41/org/osgi/framework/Bundle.html
http://blog.linkedin.com/2008/07/10/osgi-at-linkedin-integrating-spring-dm-part-2/
http://osgi.mjahn.net/2008/03/13/half-bundle-half-jar-%E2%80%93-the-nature-of-fragment-a-blessing-or-a-curse/

-o-

Creating OSGi Bundles

http://blog.springsource.com/2008/02/18/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.
http://www.jboss.org/community/wiki/JBossOSGiProjectInfrastructure

Spring Hibernate Issues
http://hwellmann.blogspot.com/2008/11/hibernate-and-osgi-elaborate-solution.html

There is no OSGi key word on entire Hibernate site.

Nice tutorial on how to build OSGi bundles
https://www.wso2.org/node/4718/print

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.
http://www.aqute.biz/Code/Bnd

Best tutorial on wraping Hibernate into Bundle
http://www.aqute.biz/Code/BndHibernate

-o-

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

-o-