Hot deploy WAR files in OSGi
These days I was looking for a simple way of deploying WAR files into OSGi. Something similar to a JEE servlet container does: I put the WAR file into a directory and it gets automatically deployed. Well, I could not find such a thing, which was easy enough to use (and do not tell me to take Spring dm Server or IBM WAS 7 Alpha something ).
So, what next? Only one option, build my own tools for such a thing. After all, how hard it could be?
I took Pax Runner to start it up easy, and provision via profiles Pax Web for WAR support (inspiration of OSGi Alliance RFC-66) and Felix File Install for hot deployment of files in a directory. Of course that was not enough as in its raw form File Install will not deploy a WAR file since it is not an OSGi bundle. It had to be first transformed. I already have a tool to transform WAR files to OSGi bundles in the form of Pax Url WAR handler (another inspiration of OSGi Alliance RFC-66), what was missing was “something” to ask me to transform the WAR to its OSGi form. Lucky me! File Install is extensible in latest versions by transformers like the one I needed. Took me 15 minutes to put in place a new Pax Web module (Pax Web Deployer), implement the transformer, build it and start it up using Pax Runner. Then I copied Sonatype Nexus WAR into the watched directory and there it was: Nexus running under OSGi. Deleted the WAR, Nexus got uninstalled. Sweet!
Want to try it out?
- install Pax Runner (note that using Pax Runner is just for convenience. What you need to get this working are just the bundles included in Pax Runner profiles and the new Pax Web Deployer)
- start the osgi framework with the following command line:
pax-run war config felix.fileinstall url mvn:org.ops4j.pax.web/pax-web-deployer/0.7.3-SNAPSHOT --repositories=+http://repository.ops4j.org/mvn-snapshots/@snapshots
- ensure that all the bundles are started
- copy your WAR into “runner/load” directory under the directory from where you started .
- watch the console to see your WAR getting deployed
- have fun with it
About this entry
You’re currently reading “Hot deploy WAR files in OSGi,” an entry on pax my framework
- December 18, 2009 / 10:34 pm