Groovy & Grails on OSGi
This series of blog posts will look at OSGi support from different angles and try to find solutions to emerging problems.
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.

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?
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.
Cheers,
Wolfgang
@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.
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.
HTH,
Wolfgang
Grails 2 JARs no longer have OSGi manifest headers. I don’t know whether this affects the plugin or not.
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.