Deploying OSGI web application as standalone application

There are two ways to deploy OSGI web application as standalone for distribution purpose:

  • As a deployable plugin feature- We would discuss this below in detail.
  • As a deployable plugin- Me and others people having problems when deploying this way. Always getting java.lang.NoClassDefFoundError: org/xml/sax/SAXException, so would not discuss this in detail.

Making struts application as deployable plugin feature

Prerequisite

    The OSGi framework is not a web container like Jetty or Tomcate. It doesn’t automatically recognize jsp pages and doesn’t compile them.  Following is the complete list of OSGI plugins that are needed for any web based application.   

  • javax.servlet.jsp_2.0.0.v200806031607.jar
  • javax.servlet_2.4.0.v200806031604.jar
  • org.apache.commons.el_1.0.0.v200806031608.jar
  • org.apache.commons.logging_1.0.4.v20080605-1930.jar
  • org.apache.jasper_5.5.17.v200806031609.jar
  • org.eclipse.equinox.app_1.0.0.v20070606.jar
  • org.eclipse.equinox.common_3.4.0.v20080421-2006.jar
  • org.eclipse.equinox.http.helper_1.0.0.200901201533.jar
  • org.eclipse.equinox.http.jetty_1.1.0.v20080425.jar
  • org.eclipse.equinox.http.registry_1.0.0.v20070608.jar
  • org.eclipse.equinox.http.servlet_1.0.0.v20070606.jar
  • org.eclipse.equinox.http.servlet_1.0.100.v20080427-0830.jar
  • org.eclipse.equinox.jsp.jasper.registry_1.0.0.v20070607.jar
  • org.eclipse.equinox.jsp.jasper_1.0.100.v20080427-0830.jar
  • org.eclipse.equinox.launcher_1.0.100.v20080509-1800.jar
  • org.eclipse.equinox.preferences_3.2.100.v20070522.jar
  • org.eclipse.equinox.registry_3.3.0.v20070522.jar
  • org.eclipse.osgi.services_3.1.200.v20071203.jar
  • org.eclipse.osgi_3.4.0.v20080605-1900.jar
  • org.eclipse.update.configurator_3.2.200.v20080417.jar
  • org.mortbay.jetty_5.1.14.v200806031611.jar
  • org.eclipse.equinox.launcher.win32.win32.x86_1.0.100.v20080509-1800 (This is one is the folder in eclipse plugin directory and not the jar)

All of these plugins are already present in eclipse plugin directory except org.eclipse.equinox.http.helper_1.0.0.200901201533.jar. We have to make this plugin jar by ourself from eclipse source code repository. See the link for creating it.

There is an excellent web cast by Elie at http://www.volanakis.de/nuggets/rap_deployment_with_jetty/rap_deployment_with_jetty.html which shows how to build plug-in Feature in eclipse although it is for RAP but the process of making feature is same.

Following is summary of making deployable plugin feature(Assuming that you have already created struts application plugin project as mentioned at this  blog link):

  • Create an empty eclipse project by selecting New–>Project–>Plug-in developement–>feature Project:
  • A screen would be presented. Type in the name of the project “org.eclipse.equinox.struts.example.feature” as shown below:osgideploypic1
  • After the project is created feature.xml would automatically opened. This file is loacated at the root of the project. You can open it by double clicking it. After it is opened click plug-in tab located at the bottom of the screen then you will see the following screen:

osgideploypic2

  • click the Add button and type the name of the struts application plugin to add it in the project.Similarly add all the plugins that struts application plugin is dependent on. You can check the list of plugin needed by opening Manifest.MF file and locating the import packages name in it.
  • Right click the feature project and click Export–>Plug-in Development–>Deployable feature click next at the bottom. In the next screen check the struts plugin box as shown below and then click Finish:

osgideploypic3

  • Now go to the folder where we exported our feature and do following:
    • copy eclipse.exe from eclipse installation folder to this folder.
    • Copy following from eclipse’s plugin folder to the plugin folder of exported feature (note some of them would already be present in the folder): 
    •  javax.servlet.jsp_2.0.0.v200806031607.jar
    •  javax.servlet_2.4.0.v200806031604.jar
    • org.apache.commons.el_1.0.0.v200806031608.jar
    • org.apache.commons.logging_1.0.4.v20080605-1930.jar
    • org.apache.jasper_5.5.17.v200806031609.jar
    • org.eclipse.equinox.app_1.0.0.v20070606.jar
    • org.eclipse.equinox.common_3.4.0.v20080421-2006.jar
    • org.eclipse.equinox.http.helper_1.0.0.200901201533.jar
    • org.eclipse.equinox.http.jetty_1.1.0.v20080425.jar
    • org.eclipse.equinox.http.registry_1.0.0.v20070608.jar
    • org.eclipse.equinox.http.servlet_1.0.0.v20070606.jar
    • org.eclipse.equinox.http.servlet_1.0.100.v20080427-0830.jar
    • org.eclipse.equinox.jsp.jasper.registry_1.0.0.v20070607.jar
    • org.eclipse.equinox.jsp.jasper_1.0.100.v20080427-0830.jar
    • org.eclipse.equinox.launcher_1.0.100.v20080509-1800.jar
    • org.eclipse.equinox.preferences_3.2.100.v20070522.jar
    • org.eclipse.equinox.registry_3.3.0.v20070522.jar
    • org.eclipse.osgi.services_3.1.200.v20071203.jar
    • org.eclipse.osgi_3.4.0.v20080605-1900.jar
    • org.eclipse.update.configurator_3.2.200.v20080417.jar
    • org.mortbay.jetty_5.1.14.v200806031611.jar 
    • org.eclipse.equinox.launcher.win32.win32.x86_1.0.100.v20080509-1800 (This is one is the folder in eclipse plugin directory and not the jar)

 

  • Now create folder called “configuration” in feature exported folder. Create config.ini file in this folder and put following contents in it:

[bundles]

osgi.bundles=org.eclipse.equinox.common@2:start,

org.eclipse.update.configurator@3:start,

org.apache.commons.logging@start,

org.eclipse.equinox.http.helper@start,

org.apache.jasper@start,  

org.eclipse.equinox.jsp.jasper@start,

org.eclipse.equinox.http.servlet@start,

org.eclipse.equinox.http.jetty@start,            

org.mortbay.jetty@start,

org.eclipse.equinox.struts.example@start

[Settings]

org.osgi.service.http.port=8080

eclipse.ignoreApp=true

osgi.noshutdown=true

  • Now you can run the OSGI standalone struts application. Open Command windows and type following to run the standalone OSGi struts application.

eclipse -console -clean -noexit

  • This open following console window showing that jetty server is running at the port we provided in config.ini file above.

    osgideploypic4

 

    Advertisements

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s