Groovy & Grails on OSGi

February 3rd, 2011 Leave a comment Go to comments

This series of blog posts will look at OSGi support from different angles and try to find solutions to emerging problems.

Grails on OSGi: Thoughts

Grails on OSGi: First steps

Grails on OSGi: Released Grails OSGi plugin 0.1

Grails on OSGi: Released Grails OSGi plugin 0.2

Grails on OSGi: Released Grails OSGi plugin 0.2.1

groovyx.osgi: OSGi DSL for Groovy

Please see this page for generic OSGi stuff

Also see the code for the OSGi plugin at GitHub.

  1. Jon
    January 30th, 2012 at 22:25 | #1

    I take it since it’s been a year and a half since the 0.2.1 release, that development on this plug-in is no longer happening?

  2. January 30th, 2012 at 22:51 | #2

    Hi Jon,

    I did not get that much feedback on the OSGi plugin and am currently working on other stuff (as time permits, the Grails OSGi plugin is a hobby only). Do you have interest in the plugin? Or do you use it already with an older Grails version? What is your environment and use case? I still want to update the plugin to Grails 2.0, but didn’t get around to it yet.



  3. Jon
    February 6th, 2012 at 19:00 | #3

    @Wolfgang Schell Thanks for the reply. I’m working with a Grails 1.3.7 app at the moment (Haven’t moved to 2.0 yet). I’m trying to get the app running as a OSGi bundle. I’m new to OSGi and have been fighting with it for a week now. I’ve been bundling a default grails app with only the OSGi plugin installed and have been getting a lot of dependency errors on startup in both virgo 2.1.1 and 3.0.2. The use case is a web platform that can be built upon by adding many separate web applications. I believe that OSGi is the answer to our problems but can’t seem to get it figured out.

  4. February 6th, 2012 at 22:40 | #4

    Hi Jon,

    the OSGi plugin replaces some of Grails’ dependencies with corresponding bundles from SpinrgSource Enterprise Bundle Repository (EBR), which contains bundle-ized versions of many standard java library. The problem is, that these dependencies are currently more or less hard coded. You might be able to get it to run by tweaking scripts/_Osgi.groovy and scripts/_Events.groovy, where all the replacement bundles and dependencies are defined. You can find the complete source code of the OSGi plugin here.

    When running it in Virgo, you should remove all tomcat bundles referenced in the scripts mentioned above, as Tomcat is provided in the Virgo Web and Virgo Nano Web installations.



  5. Peter Ledbrook
    March 20th, 2012 at 16:52 | #5

    Grails 2 JARs no longer have OSGi manifest headers. I don’t know whether this affects the plugin or not.

  6. March 21st, 2012 at 07:33 | #6

    Hi Peter,

    thanks for the heads up!

    Yes, that would affect the plugin if used in a modular manner (more below). But when running a WAR-ed Grails app as a monolithic OSGi bundle (see here for a definition of monolithic in this case), it should still work, though. I saw another commit yesterday, which disables generation of OSGi headers when generating a WAR file. But as this can still be activated in (Build)Config.groovy, this shouldn’t matter too much.

    Do you know why the Grails JARs no longer contain OSGi headers? That would affect running a Grails app (or multiple thereof) in an OSGi container in a modular manner, i.e. with each Jar as its own bundle.

    But as the OSGi plugin does not currently work with Grails versions newer than 1.3.4 (or so), I’ll have to update it anyway.

  1. July 12th, 2010 at 02:08 | #1
  2. September 24th, 2010 at 13:54 | #2
Fork me on GitHub