This Blog is in continuation of my first blog on OSGi.
In the first part we saw what OSGi is and what benefits it offers. In this section I would like to share my experience in evaluating OSGi for developing a Web based application, the challenges I faced, Spring DM server and DM Server development tools for developing OSGi applications. Next I would also share some of my experience in using Spring DM Server for an actual development project
After doing my initial research of the OSGi framework I decided to start my journey on developing a sample Web based application on OSGi.
I soon realized my research is not complete and I still had to explore on how to integrate a Web based application within an OSGi container. I also had to explore on the development tools to be used.
Challenges in developing an OSGi based web application
I faced an interesting challenge here. OSGi applications need to work within an OSGi container whereas Web applications run within a Web Container.
To resolve this issue one can either embed the Web Container bundle (Tomcat bundle or Jetty bundle) within OSGi container or deploy the OSGi platform as a war within the Web Container. I particularly didn’t find these approaches amusing but with no other option left chose the first option.
Oops faced one more challenge here. Tomcat bundle was not readily available. I went through various forums and site where they explained how to build a tomcat bundle. Not to delay my progress I decided to use Jetty bundle which was readily available. It did take time for me to do the initial setup but finally I was set to start my development.
I was using PAX-Construct for handling the OSGi container and for deploying the various OSGi bundles. I went through the various steps that are required to develop a bundle and deploy it using PAX- Construct .I tried a few examples and found the steps to be too exhaustive and time consuming. Searching the open source library bundles manually, installing them and updating the Manifest file was becoming a nightmare. Instead of focusing on business logic my major time was getting spent in OSGi related activities.
My excitement about OSGi was coming down and I was thinking may be OSGi development tools are not matured enough and OSGi is best suited only for desktop based application. I wanted to have a simple deployment container for OSGi Web applications and easy to use development tools.
I wanted to do more research in this area before coming to a final conclusion and so I continued my research on OSGi in the web mode.
After going through several sites and forums I found the OSGi Enterprise Experts Group is working on the RFC66 standard for OSGi web container. I also came across several claims about Spring DM server being the best reference implementation of the standard. I didn’t come across any other implementation of the standard so couldn’t do much of the comparison here and finally decided to do more analysis of the DM Server.
Just after spending a couple of hours on the Spring DM server I found SpringSource has resolved both of my previous concerns. Spring DM Server served as a ready platform for deploying OSGi based web applications and Spring Source DM Server Tools provided very good Eclipse development environment for Spring DM server based applications.
Let’s have a look at what Spring DM Server and its development tools provides us
Spring DM Server
- Spring DM Server is a lightweight, modular, OSGi-based runtime that provides a complete packaged solution for developing, deploying, and managing enterprise applications.
- The SpringSource dm Server is built on top of the following core technologies:
- Spring Framework
- Tomcat as the web container.
- OSGi R4.1.
- Equinox as the OSGi implementation.
- Spring Dynamic Modules for OSGi for working with OSGi in a Spring application.
- SpringSource Tool Suite for developing applications.
- Spring Application Management Suite for monitoring the SpringSource dm Server and the applications that have been deployed to it.
Key Capabilities Include:
Admin Console: deploy and manage artifacts, examine diagnostic dumps, and examine bundle wiring, either in the live system or from a resolution failure
Equinox console extension – manage DM Server and deployed artifacts
Plans - define the artifacts that comprise an application, optionally making the application atomic to tie the artifact lifecycles together, and scoped to isolate the application from other applications
Provisioning - automatically supply the dependencies of an application including bundles, plans, plan archives (PARs), and configurations, from both local and remote repositories
Web container - supports vanilla WAR files, with all their dependencies in WEB-INF/lib, and Web Application Bundles, that import their dependencies via OSGi manifest metadata, via the embedded Tomcat-based reference implementation of the OSGi Web Container specification, configured using the standard Tomcat server.xml
User Region - isolates the kernel from user-installed applications and enables admins to focus on application artifacts and their dependencies without seeing those of the kernel as well
Spring 3 –Spring DM Server packages Spring 3.0 final, but can easily be configured to use a different version of Spring.
Hot deployment - deploy artifacts to Virgo by copying them into the pickup directory, either in archive or exploded form, as an alternative to deploying via the admin console
Logging - via embedded LogBack, configured in config/serviceability.xml, with a rich set of appenders available out of the box
Spring Source Tool Suite
SpringSource provides a set of plug-ins for the Eclipse IDE that streamlines the development lifecycle of OSGi bundles and PAR applications. The SpringSource dm Server Tools build on top of the Eclipse Web Tools Project (WTP) and Spring IDE, the open-source Spring development tool set.
The SpringSource dm Server Tools support the creation of new OSGi bundle and PAR projects within Eclipse, and the conversion of existing projects into OSGi bundle projects. Projects can then be deployed and debugged on a running dm Server from within Eclipse.
Experience of using Spring DM Server in Live Project
I developed a sample Web application based on Spring DM server and its development tools. Once all stake holders were convinced we decided to use it for our next development project.
At the time of writing this blog its beings six months we have been using Spring DM server in actual development. Following are some of my experiences in this period:
- Technical Documentation: Spring Source has come up with a detailed documentation for setting up the server and developing/migrating a web based application using Spring DM server.We were able to resolve most of our setup and development issues by referring to the Spring Source provided documents. We also got answers to most of our queries from Spring DM server forums but still there were some situations where in we had to struggle for our problems.But overall we would rate the documentation and the forum support to be fairly good.
- Spring Source Repository: Spring Source has come up with an online repository where you can find OSGi bundles and libraries for all major Java open source libraries. For our development project we were able to find 95% of our open source bundles readily available here which saved our search time to a great extent.
- Hibernate integration: It was very easy to integrate Hibernate in our application. The OSGified Hibernate Library was readily available with the Spring Source repository and we had to follow the standard Spring – Hibernate integration process.
- Axis 2.0 integration: We faced lot of issues here. The Axis 2.0 bundles were not readily available. There were some sites which OSGified the bundles but deploying these was causing lot of version conflicts with other bundles.Since the Web Service code was part of a single web bundle and was not required to be decomposed into smaller bundles we decided to use the normal Axis 2.0 libraries. We deployed the standard Axis2.0 libraries in the lib folder of our web bundle and were able to integrate Axis without further issues.
- Tiles Integration: Again we faced bundle conflict issues here. There were version conflicting issues with the Tiles library and Spring 3.0 Library. To resolve the issue we had to provide reference to a couple of core Spring 2.5 library
- Spring DM Server integration within Eclipse: The development tools provide seamless integrations of Spring DM server with Eclipse. We were able to Start, Stop the server, Deploy and Redeploy PAR files from within Eclipse easily. Debugging the application code was also very easy and we had to follow the standard debug process here.
- Deploying Open source bundles from the development environment: This is one of the best features provided by the development tools. The development tools provide easy integration with various online repositories from where the OSGi bundles/libraries can be downloaded and integrated for an application. Using this feature we were able to search and deploy open source OSGi bundles and libraries easily for our application.
- Manifest file manipulation from Development environment: The development tools provide an excellent User Interface for importing packages from other bundles and for exporting packages of a bundle. The actual Manifest file is automatically generated based on the selections made from the User Interface. This saves lots of Manifest file management hassles.
- Using Maven for continuous Integration : We are still doing research in this area. Our intial research suggests using Maven for build process results in losing lots of benefits offered by the development tools. At the moment we are using only the development tool for building and deploying the PAR project but we would definitely want integration with Maven to streamline the integration and build process.
To conclude OSGi provides a great platform for building modular Java applications in a true sense. OSGi is proven technology adapted by many open source and proprietary Java Enterprise servers and applications .Spring DM server looks promising as an OSGi web container and the DM server tools greatly simplify the OSGi development tasks. With the standardization of the OSGi web container specifications and Spring Source being actively involved in its implementation we would expect adaption of OSGi in many future Java Web application developments.
Finally I would support the quote posted on Spring Source site by Jan Hendrik Kuperus ‘ Spring DM Server is the future of Java EE’.
PS: At e-Zest, we work on emerging technologies & solutions based on OSGi component framework & Enterprise OSGi specification. Please feel free to email me your queries regarding OSGi on our corporate email id: firstname.lastname@example.org.