I worked on the Eclipse Equinox project to bring the OSGi framework up to
the OSGi R4 specification.  As part of that I did some prototyping of
Geronimo on OSGi.  I have recently revisited this work and have got
Geronimo starting successfully on OSGi.  Since there has been some
discussion of Geronimo and OSGi on this mailing list recently I thought it
might be useful to post what I have done.

I started with Geronimo milestone build M4 (the latest build when I
started).  Apart from a couple of minor changes, the Geronimo code is
untouched.  This means that it is still using the GBean framework within
OSGi.  There were no changes to the OSGi framework.

The OSGi bundles (listed below) directly map to the Geronimo jars:

         geronimo-common
         geronimo-core
         geronimo-deploy-config
         geronimo-deployment
         geronimo-j2ee
         geronimo-j2ee-schema
         geronimo-kernel
         geronimo-management
         geronimo-naming
         geronimo-spec-ejb
         geronimo-spec-j2ee-connector
         geronimo-spec-j2ee-deployment
         geronimo-spec-j2ee-jacc
         geronimo-spec-j2ee-management
         geronimo-spec-jta
         geronimo-spec-servlet
         geronimo-system
         geronimo-transaction

To make these projects into bundles I added OSGi meta-data into a manifest
file.  This defines the dependencies of the bundle.  As an example here is
the manifest for geronimo-common:

      Manifest-Version: 1.0
      Bundle-ManifestVersion: 2
      Bundle-Name: geronimo-common
      Bundle-SymbolicName: geronimo_common
      Bundle-Version: 1.0.0
      Bundle-Localization: plugin
      Import-Package:
       javax.management,
       org.apache.geronimo.kernel,
       org.apache.xmlbeans
      Export-Package:
       org.apache.geronimo.common,
       org.apache.geronimo.common.propertyeditor
      Bundle-ClassPath: bin/, .

In addition to this I had the OSGi system bundle from Eclipse
(org.eclipse.osgi) - I just used the latest version from HEAD in the
Eclipse CVS repository (anonymous pserver access to
'dev.eclipse.org:/home/eclipse'), though any version (3.1 or later) should
be ok (binaries of the OSGi framework are available from
http://download.eclipse.org/eclipse/equinox).

Geronimo is dependant on quite a lot of non-Geronimo code (e.g.
commons-logging, mx4j, etc), and so I grouped all of these jars into a
single bundle (called 'other') and set up some appropriate meta-data for
it.  I also had to add in 2 more jars to this project - one with
org.objectweb.asm, and one containing the JSR173 packages.

As I mentioned earlier there were a couple of minor changes to Geronimo (in
geronimo-system).  The first was in
org.apache.geronimo.system.main.Daemon.doStartup().  I was getting a
failure from some of the code in here because "startup-jar" does not
contain a manifest.  I'm not sure how this would normally work.  I just
commented out the lines that used the manifest.  The other change was to
the static initializer in
org.apache.geronimo.system.serverinfo.DirectoryUtils.  It was using a
JarURLConnection, but running in OSGi, it gets returned a
BundleURLConnection, so I modified it to use this instead.  Finally I added
a bundle activator to geronimo-system so that the bundle could be started.
This activator simply calls the main() method in Daemon.

Once all this had been done I could start up Geronimo on OSGi (using either
the Eclipse OSGi console or my own launcher program).  I can make this work
available if people are interested.

Simon.

Reply via email to