Wednesday, December 19

Using OSGi? Need logging?

We're very close to the first major release of Pax-Logging - if you're using OSGi and are still looking for a good logging provider, why not try the release candidate:



several major open-source projects are already using it to simplify their logging story.

Tuesday, December 18

An introduction to Pax tools for OSGi

I received an early Christmas present this year: my proposed tutorial for EclipseCon 2008 was accepted! Come along if you want to hear how Pax-Runner, Pax-Construct, Pax-Logging, and the rest of the Pax family can make life with OSGi much more bearable :)

Both Alin and I will be there to go through the tools, run demos, suggest OSGi best-practises, and answer questions. BTW, if you have any specific topics you'd like covered, let me know and I'll see if I can work them into the tutorial.

Hope to see you at EclipseCon 2008.

Tuesday, December 4

Pax Construct 0.6.2 Released

Moving to 0.6.2

You can update existing scripts and projects with the pax-update command. Or you can download the new scripts and manually change the maven-pax-plugin version in your project's pom.xml.

Change Log


  • [PAXCONSTRUCT-52] - pax-clone has issues with java files containing #. and #stop
  • [PAXCONSTRUCT-53] - pax-clone corrupts binaries
  • [PAXCONSTRUCT-54] - pax-validate.bat fails when invoked from cygwin
  • [PAXCONSTRUCT-55] - pax-import-bundle throws NPE when run outside of a maven project - it should report an error instead
  • [PAXCONSTRUCT-56] - pax:eclipse error using latest 0.6.2-SNAPSHOT
  • [PAXCONSTRUCT-57] - Support using Pax-Construct scripts in a directory with spaces under Cygwin


  • [PAXCONSTRUCT-50] - maven-pax-plugin can cause long compilation times when unpacking bundles with embedded dependencies
  • [PAXCONSTRUCT-58] - Add provided dependencies as required libraries in the Eclipse classpath to better support testing


  • [PAXCONSTRUCT-51] - Separate archetypes from the main pax plugin and scripts so they can be released separately

Thursday, November 29


Just thought I'd share a picture of our new cat Oatmeal (or Oatey for short) who we got several weeks ago from a rescue organization. He's settled in very quickly and enjoys distracting me when I use my macbook at home - I'm beginning to suspect my wife is encouraging this behaviour ;)

this is Oatey in "cute" mode (warning: he also has a "biting+scratching" mode!)

Wednesday, November 28

EclipseCon 2008

Well, the submissions are in and it looks like there are some really great talks and tutorials out there - it's a shame there's only so much time available. There was a flood of OSGi related submissions just before the deadline, so Peter can rest easy ;)

If you want to see what's available, take a gander at:

the submissions process is open and transparent, so feel free to review them and comment on those you'd like to see, or ask for more details on any talks/tutorials.

Hope to see you at EclipseCon next year!

mmm... durian

One of the benefits of living in Malaysia is the wide range of food available*. It took me a while to get used to eating durian fruit, as the smell reminded me too much of ripe cheese - but now my wife and I can happily eat several in a single sitting.

I don't know exactly when it happened, but one day I was drawn to the smell rather than it putting me off - since then I look forward to durian season and enjoy savouring the different flavours and textures you can find here and in Indonesia. Every fruit is different - and now and again you find a really great durian that you just wish you could eat again :)

These days you can find durian in ice-cream, candy, mooncakes - even doughnuts!

perhaps this could even make Homer Simpson try durian?

(* I also like Indonesian salak but it's hard to find good supplies of this locally)

Wednesday, November 21

Pax Construct 0.6.1 Released

if you have 0.6.0 installed, you can use pax-update to upgrade your existing scripts (must be run from inside the scripts bin directory).

Release Notes - Pax Construct - Version 0.6.1


  • PAXCONSTRUCT-47 - Default classpath entry for an imported bundle is missing when source is unavailable


  • PAXCONSTRUCT-46 - Use latest release of Pax-Runner by default, instead of always defaulting to a known static version
  • PAXCONSTRUCT-49 - resources out of basic resource path included in details.bnd not copied when cloning, or fix for bundle build

New Feature

  • PAXCONSTRUCT-48 - Allow users to specify a different bundle groupId, rather than limiting them to the generated groupId

Friday, November 9

JayView Issue 14: OSGi - not just a four letter word

The latest issue of the Jayway magazine, JayView, is now out:

   JayView issue 14

it includes an article I wrote recently about OSGi - let me know what you think... (FYI, the cover shows the Petronas Towers, which are visible from the office where I work in Kuala Lumpur)

Wednesday, November 7

Peaberry: injecting OSGi services using Guice

Several months ago I blogged about Guice-OSGi, my OPS4J research project looking at using Guice to do dependency injection of OSGi services. Since then I've been distracted with other projects, moving house and our new cat (who almost managed to rewrite my DevCon submission when he took an keen interest in my MacBook, and then managed to disconnect the ADSL line - what a critic!)

Anyway, it seems that to officially use OSGi in a project name it must be an adjective, which is why Spring-OSGi has transformed into: "Spring Dynamic Modules for OSGi(tm) Service Platforms". Rather than try to compete with an equally long title, I decided to resurrect a name I'd previously used for a demo project: "peaberry", which is a special type of coffee bean. (as my wife will tell you, I really like coffee...)

So peaberry is the new Guice-OSGi, and is now hosted over at Google Code:

I decided to host the project there rather than at OPS4J because it makes it easier for people who know the Guice site to find their way to peaberry. BTW, if you're interested in helping out, let me know and I'll add you to the project team.

I've just made the first download available:


which is an OSGi bundle of the latest trunk version of Guice with patches for issue 49 (binding factories) and issue 94 (classloader interception of generated classes) which are needed to use Guice in a reloadable container, such as OSGi. Hopefully these patches will eventually be folded back into the main Guice tree.

The next step is to install a 'bridge' classloader (based on issue 94) to allow generated classes to see both the internal Guice code and external user classes without needing DynamicImport-Package:* in the peaberry bundle. After that I plan to migrate the Guice-OSGi annotation work over to peaberry (based on issue 49) and remove the need to extend a specific base class to bootstrap the service injection process.

As mentioned in my last post, I've submitted a talk about my work on peaberry to the DevCon site, so if enough people are interested I may get the chance to explain all the cool features in person.

Tuesday, November 6

OSGi DevCon/EclipseCon 2008

Only a couple more weeks left to submit talks or tutorials for the next OSGi DevCon. I've submitted one tutorial and a talk so far:

An introduction to Pax tools for OSGi

OSGi service injection using Guice

Have you got an interesting story or project involving OSGi? If so then submit it soon - I don't want to be the only speaker :)

Friday, October 19

Migrate existing OSGi projects to the latest Pax-Construct

I'm currently tinkering with a Maven mojo to help people migrate old Pax-Construct (0.1.x) and other OSGi projects to the new Pax-Construct layout. At the moment this mojo only captures the project layout and types of bundles (wrapper, compiled, imported, etc.) but will eventually include the actual bundle source, BND instructions, and other POM customization - like extra repositories.

To try out the new mojo, either download the latest 0.2.1-SNAPSHOT scripts and use the pax-validate command to pull down the latest maven-pax-plugin, or build from the latest sources.

Then go to your OSGi project and call:

mvn org.ops4j:maven-pax-plugin:0.2.1-SNAPSHOT:clone

which should generate both UNIX and Windows build scripts under the target folder.

Make sure the 0.2.1-SNAPSHOT Pax-Construct scripts are on your path, and cd to a temporary directory - you should then be able to call the generated build script, which will recreate the project structure using the latest Pax-Construct commands.

For example:

cd ~/Code/ops4j/pax/radman ; mvn org.ops4j:maven-pax-plugin:0.2.1-SNAPSHOT:clone

cd /tmp ; ~/Code/ops4j/pax/radman/target/pax-clone-radman

If you want to make sure there's only one main project, use the -DunifyRoot Maven property to bring any disconnected (ie. parent-less) modules under the same root project.

Feel free to try it out and feedback any issues / requests via the OPS4J JIRA site as usual - enjoy!

Friday, October 12

Rapid OSGi development : Pax-Construct 2 goes GA

I've just made the new version of Pax-Construct generally available on the OPS4J repository:

detailed documentation for the scripts and Maven2 plugins can be found on the following site:

including an example of using Pax-Construct to assemble and deploy Spring Dynamic Modules!

Other noteworthy features:

  • much simpler project layout - you can even create standalone bundle POMs
  • transitive wrapping of third-party jars and their dependencies
  • transitive importing of OSGi bundles and their bundle dependencies
  • new scripts to help move bundles around the project
  • supports the latest release of Pax-Runner!
I'm away in Penang for the next few days, but will be back soon to answer questions and provide many more examples. In the meantime, feel free to comment on the wiki, or raise issues on JIRA :)

Launching Spring Dynamic Modules using Pax-Runner

My fellow OPS4J'r Alin Dreghiciu has produced a really cool screencast showing how you can quickly deploy Spring-OSGi M3 using his recently released version of Pax-Runner:

You can also read more about the ongoing Pax-Runner story at:

Support for the major OSGi frameworks, flexible configuration, directory and maven scanners - what more could you want? (if yes, please mention it on JIRA!)

Alin's screencast is now linked from the Spring Dynamic Modules site:

well done Alin!

Monday, September 24

documentation for the maven-inherit-plugin

I've uploaded some documentation for the maven-inherit-plugin in the usual format:

and improved the code to use custom Javadoc tags to get the extended plugin details.

For example:

* @extendsPlugin archetype
* @extendsGoal create
* @goal create-project
* @requiresProject false
public class OSGiProjectArchetypeMojo extends MavenArchetypeMojo
// if you override member fields, remember to propagate the values using reflection

Tuesday, September 18

Simple Maven Plugin Inheritance

Pax Construct extends a number of other maven mojos from the archetype, compiler and eclipse plugins. Extending maven mojos is a bit of a pain at the moment, because plexus (the component manager used by maven) relies on javadoc comments to generate the plugin XML. Unfortunately when the parent mojo is provided by an external project, the javadoc isn't available to plexus.

At first I relied on duplicating parameters in the sub-mojo to trick plexus into creating the right plugin XML, then used reflection to forcibly update any private fields in the parent mojo.

Maintaining these parameters was a bit of a nightmare, so I developed a new plugin called the maven-inherit-plugin to help with the plugin XML. It attempts to merge the various plugin XML fragments and warns about any potential field clashes that would require reflection.

To use it in your plugin pom, add the following XML:




It looks for dependencies of type "maven-plugin" and will merge the XML fragments describing their goals with any matching local goals that have the following syntax:

@extendsPlugin {plugin}
@goal {local-goal}

If you want to rename a inherited goal, use this syntax:

@extendsPlugin {plugin}
@extendsGoal {inherited-goal}
@goal {local-goal}

For example, in Pax-Construct I extend the archetype goal into a number of sub-goals, such as:

* @extendsPlugin archetype
* @extendsGoal create
* @goal create-project
* @requiresProject false

Overridden fields generate a warning at compile time and must be updated using reflection. See the main pax plugin for examples of using this technique to add behaviour to existing plugins.

Source code is available from:

(updated to show new javadoc tags)

Calling all testers! Pax Construct v2 beta1

Well, we've finally completed the move to our new home and are slowly unpacking boxes "on-demand" :)

Meanwhile, back at OPS4J I've finished a major refactoring of the Pax Construct plugin and slimmed down the archetypes to produce a much leaner project layout. The more adventurous of you might like to try out the beta version:

Be warned - the usual beta disclaimers apply! Especially since the only machine I have with Windows is still packed away, and so all testing so far has been on my macbook using Ubuntu (my main development environment). Also, the docs are woefully out of date - at this moment the code is the best documentation, but you can use -h with any of the scripts to get basic usage.

Second warning: Pax Construct v2 is not compatible with projects created using older versions, but a script is being developed to migrate projects to the new layout. However you can use v2 to create and manage new projects.

Some highlights of v2:
  • Transitive wrapping - you can choose to embed dependencies, or create further wrappers
  • Transitive import - provided dependencies of imported bundles are automatically added
  • Simple import management - the import list is maintained inside a single provision pom
  • Optional generation of Eclipse project files - use "mvn clean install -Peclipse"
  • Enhanced compilation - supports compiling against bundles with embedded jars
  • Refactoring support - bundles can be moved around, poms will be created as necessary
  • Improved maven mojos - can be used inside other poms to create projects for testing
Here's a couple of wrapping examples, which should be done inside a project created with pax-create-project - the first creates a bundle with embedded dependencies (use "mvn clean install" to build it) the second replaces it with a series of bundles, one per dependency:
pax-wrap-jar -g commons-logging -a commons-logging -v 1.1 -- -DembedTransitive

pax-wrap-jar -g commons-logging -a commons-logging -v 1.1 -- -DwrapTransitive -Doverwrite
A more complex example involving Spring-OSGi can be downloaded here:

Spring-OSGi deployment script (unix)
Spring-OSGi deployment script (windows)

Download the script for your OS, make sure the v2 scripts are in your path and run it - it should build and deploy a basic Spring-OSGi setup based on milestone 3, along with some wrappers and the weather sample. (note: it can take a few seconds to startup on Felix, the default framework)

There's a lot of cool stuff behind the scenes, and I'm starting on proper documentation for it this week. BTW, if you find any bugs with beta1 please raise them at while I work on the docs :)

Sunday, July 22

Our new home

Hayfa and I are now home-owners! Picked up the keys to our new condo apartment yesterday, and spent most of this weekend discussing paints, what should go where, etc. (we're both fairly easy-going so it takes us ages to decide anything!)

Friday, July 6

Better dependency management with Pax Construct

Had some really useful discussions during the OSGi Community Event in Munich about wrapping complex artifacts such as Hibernate3. The next drop of Pax Construct will try to handle dependencies for you as much as possible (automatically embedding / wrapping / importing them as required) so with one command you can drag an artifact into your OSGi project without having to repeatedly deploy or compile to track down those annoying missing dependencies.

Also planned: OBR support to search for artifacts based on your bundle's imports :)

As ever, let me know via JIRA or email if there's anything that would make OSGi development that little bit easier!

Tuesday, July 3

OSGi Alliance Community Event talks now online

My talk from the 2007 OSGi Alliance Community Event is now online:

along with slides from all the other talks - well worth perusing.

Saturday, June 23

Guice-OSGi 0.1.0 released

FYI, I've just made an initial drop of my Guice-OSGi laboratory project:


which lets you use Guice to access / register OSGi services - for example:

ExampleService exported;

would register the object injected into 'exported' as an OSGi service, and:

ExampleService imported;

would inject a proxy into 'imported' which delegates to the OSGi service.

example (use 'mvn clean install pax:provision' to try it out)

It's capable of lots more (custom LDAP filters, injected listeners, etc.) but I have a flight to catch in a few hours and need to finish my packing :) The integration tests checked into subversion contain more examples.

It doesn't do everything Spring-OSGi does, but then again it is only one bundle of ~500k ;)

(PS. I've also released 0.1.6 of the Pax Construct tools - busy week!)

Tuesday, June 12

The dreaded disk0s2: 0xe0030005 (UNDEFINED)

I've had my macbook for nearly five months and use it as my primary dev box. Last month I took it with me to Sweden to run some OSGi tutorials - before the very first session I calmly closed the lid, wandered over to the conference room and opened it up to see... nothing!

People were already wandering in so decided to do a quick reboot - but instead of the reassuring apple logo I now saw a flashing question mark folder (gulp). Luckily the tutorial was available on the intranet (FYI, it's based on Pax Construct) so I was able to grab a spare laptop and continue.

Anyway after the tutorial session I absentmindedly turned on my macbook, which now started ok!

So is this a new mac feature, auto-repair? Sadly not... since then its behaviour has been erratic - occasional beach-balls, looking like the system had frozen only to return after a few minutes. Tried turning off spotlight indexing (nice performance boost) which helped for a bit but the problem returned. Tried a full archive, erase and re-install with minimum setup which I thought had nailed it, but this weekend my macbook went totally rosak :(

No hard disk, nothing... nowhere to reinstall MacOSX, no chance of recovering data - thankfully I still had the full image backup from a few days ago (plus most of my work is online these days).

So my macbook is now at the local Apple support centre and I'm back to using my trusty Linux box that I built from scratch (and ironically contains a still-working HDD I rescued from an ancient Dell laptop and now use for temporary storage).

So here's the MOTD... if you see any errors like the following in your system log:

disk0s2: 0xe0030005 (UNDEFINED)

make sure you have any critical data backed up and get your macbook checked out asap.

Wednesday, May 23

Pax Construct 0.1.5

Hi folks,

By popular demand I've released Pax Construct 0.1.5

This release has the following improvements:

* simpler project layout
* support for adding repositories, removing bundles, embedding jars
inside bundles, and using bundles (ie. inter-bundle dependencies)
* better error checking and recovery

that makes it a lot easier to construct more complex OSGi projects.

Remaining issues have been pushed to 0.1.6, which is targeted for
mid-to-late June, and will include the project snapshot feature along
with (hopefully!) more documentation and samples.

Please let me know if you have any problems using this new release.

Cheers, Stuart

Giving a talk at the OSGi Alliance Community Event

Just found out that my talk on using Maven to build OSGi projects has been accepted for the "short talks" section of the OSGi Alliance Community Event!

So, now there's even more reason to attend the event - if only to ask difficult questions / heckle ;)

OSGi Alliance Community Event, June 26th-27th Munich, Germany

Wednesday, May 9

Convert local Maven repository into remote mirror

Almost finished my round of OSGi tutorials in Malmo, Sweden. It's been a busy time, last weekend I had two sessions back to back from 0830 to 1900! Things are a bit quieter now, so I'm going to spend time on the 0.1.5 release of Pax Construct, improving it based on feedback from the tutorials. I'm also going to add a command to create a template of a bundle that embeds a jarfile, which should make various people happy.

Anyway, on to the real topic of this post - in creating the tutorial I wrote a couple of useful scripts which let you convert your local Maven repository into a remote repository, by fixing up the necessary maven metadata and adding SHA-1 digests. You can grab the scripts from my OPS4J page at

I used these scripts to create an offline repository for the tutorial - by just cleaning out my local repo, running through all the exercises, copying the local repo to another location and running the scripts to add the missing metadata (see example on the !sh page). I also provided a modified settings.xml file which added mirror repos relative to the maven installation (such as file:${M2_HOME}/../../artifacts) for all the main repo ids.

This mean people could work the tutorial offline, and also meant that even when online the network wasn't hammered by everyone downloading exactly the same set of artifacts... the only downside is the extra work keeping the mirror up-to-date.

Thursday, April 26

Guice and OSGi

I recently wrote a patch for Guice, which adds OSGi metadata to the jarfile and fixes some classloader issues when running on OSGi. Just apply this patch to the current Guice trunk (and copy the attached bnd-0.0.130.jar to the lib/build folder) and do "ant clean dist".

You can now take the Guice jar from build/dist and use it in any OSGi framework - there's an example over at OPS4J:

( btw, peaberry is a simple entity framework to test Guice and AOP on OSGi ... it only provides partial entity bean support, hence the name: Peaberry ;)

Tuesday, April 24

OSGi Alliance Community Event

OSGi Alliance Community Event, June 26th-27th Munich, Germany

Should be interesting - I'm thinking of going, as I'll be in Europe for June/July.

Monday, April 23

Quick OSGi projects using Maven archetypes

Have you ever wanted to try OSGi, but found setting up the build and working out the manifest too much of a chore?

If so then help is at hand - over the last few months, I have been developing a set of Maven archetypes and plugins to automate much of the manual work required in creating an OSGi project. Recently I also provided Windows batch files and Linux shell scripts to make it even easier:

All you need is Maven2 and a Java5 runtime - the best part is the OSGi manifest attributes are automatically calculated for you by Peter Krien's wonderful bnd tool, connected to Maven by the maven-bundle-plugin from the Apache Felix project.

For example, the following commands would create a simple skeleton OSGi web application ... and deploy it to Equinox:

pax-create-project -g simple.project -a osgi-web-app

cd osgi-web-app

mvn install

pax-wrap-jar -g javax.servlet -a servlet-api -v 2.5
pax-import-bundle -g org.ops4j.pax.logging -a api -v 0.9.4
pax-import-bundle -g org.ops4j.pax.logging -a jcl -v 0.9.4
pax-import-bundle -g org.ops4j.pax.logging -a slf4j -v 0.9.4
pax-import-bundle -g org.ungoverned.osgi.bundle -a http -v 1.1.2
pax-create-bundle -p my.osgi.code.myBundle -n myBundle

mvn install pax:provision

all you need to add is the internal application code ;)

Tuesday, February 27

Bali 2007

Photos of our recent trip to Bali - we set off on Valentine's day (along with Hayfa's parents) to Jimbaran in the south of Bali, and spent most of our trip enjoying the culture and scenery around Ubud. Had a really good time - many thanks to Pak Gusti for showing us round!

Saturday, February 10

My new macbook

I've always wanted to try out a mac, and the recent batch of Intel Core 2 Duo macbooks really caught my eye. However, I managed to resist the temptation last year ... as my wife Hayfa kept reminding me, we didn't need more computers cluttering up the house (we already have a dell laptop and an AMD64 desktop that I built in the UK).

Anyway, recently I moved to a new job (working on OSGi stuff) and this triggered a new bout of window ...err... mac-browsing. I'd been looking at the 2GHz mid-range model, but it wasn't in stock in KL. Then one weekend when Hayfa was in Penang (funny how I buy these things when my sayang isn't around) I saw an advert for MacCity in Cineleisure - RM3999 for the basic model for the first 10 customers between 3 and 5pm, a saving of RM400!

So I drove to Cineleisure, parked, wandered over to the store just before 3pm, mulled things over a bit, decided to queue and got the next-to-last one!

I'm very happy with my macbook - didn't take long to get used to the single mouse button (even starts to make sense!) and the mac command key. Even happier once I got fink and iTerm installed - in fact, it's now replaced my development machine at work!

Hayfa was pleased with my purchase in the end, because we don't have to fight over using the dell while we sit on the coach ... and it didn't take long (I think under an hour) for her to 'persuade' me to add a login for her on the macbook :)

So... if anyone wants a dell, let me know ;)

Spring Flowers

A bargain at only RM16 from IKEA :)

Friday, February 9

I miss snow

My parents just sent me this photo of the view from their house, brrrr...