Eclipse RCP/OSGI Classloader HOWTO

I am working on a new desktop application using Eclipse Rich Client Platform (RCP). Eclipse RCP applications are comprised of plugins. The plugins are not any ordinary old plugins. They are Open Standard Gateway Initiative (OSGI) plugins.

One feature of OSGI plugins is classpath separation. One plugin can be running dom4j 1.5 and another dom4j 1.6, and there is no conflict. A nice idea. Unfortunately, a combination of an extraordinarily poor user interface in the Eclipse IDE coupled with a classloader that goes out of its way not to load classes, makes it very difficult for the newly initiated to get going.

While I was away at OSCON2005, a developer on the project spent 8 full work days trying to figure out how to get our plugin to a load classes from a jar. While I was at OSCON I met Scott Delap. Scott is the maintainer of and knows a lot about RCP. Having taken a quick look at the problem myself and finding no documentation on to get the Eclipse IDE to do the right magic I called Scott. He helped through a fairly involved process, and one that is dependent on order and I was then able load jars!

With agreement from Scott, I am making the HOWTO available below. It covers:

  • Loading classes from jars.
  • Exporting classes to make them visible to other plugins.
  • Swapping in another classloader to load resources.

Eclipse 3.1 OSGI classloading HOWTO

hloader 0.7 released – easy object loading for Hibernate3

Hloader is a tool for persistent object instances, expressed in XML, into a database using Hibernate. It is a Hibernate loader, thus the name.

It can be used for:

  • loading reference data
  • loading bootstrap data
  • loading test setup data

More than anything, hloader extends an near zero cost of change to this data, thus supporting the Agile approach of evolving your database design along with you code.

This version brings support for Hibernate 3 and much comprehensive documentation.


O’Reilly Open Source Conference Coverage

OSCON 2005 kicks off tomorrow 1 August 2005.

I am here all week and am planning to update this blog entry with news and other tidbits.

Wednesday – Keynotes and Sessions

Tim O’Reilly

Tim has some interesting visualisation tools for book sales. Of interest to me personally was that C# declined last year and Java gained. The ratio of Java books to C# books sold is about 10:1. On job advertisements, Java is 16% to C#’s 4%. The irony in all this is that I now have two C# books, both O’Reilly: one called C# in a Nutshell, and a Mono Workbench book handed out in yesterday’s session.

Perl continues its long decline. Python continues to slowly build. Ruby has appeared just in the last 6 months and is growing rapidly.

Kim Polese

Kim was the original project manager for Java, while at Sun, and has been famous ever since. She is now at SpikeSource and was talking about the corporate use of runtime Java classes. She was surprised that a small number of components (20-30) are used by most companies. I was pleased to see one of my own contributions (ehcache) appear in her slides. Having surveyed this myself, I am not. SourceLabs, another open source services company has recognised the same thing. Both are providing testing and certification of predefined and custom stacks.

Andrew Morton

Andew, a fellow Aussie, is now at OSGI. He is the maintainer of the 2.6 kernel. He took a swipe at Sun for persisting with Solaris beyond its used by date.

Craig Mclanahan – Comparison of Web Frameworks/Matt Raible Spring

Struts, WebWork, Tapestry, Spring and JSF. Craig who knows a little bit about this topic, being behind Struts and JSF. A show of hands indicated most people were (still) using Struts. Spring is the current hot framework. A lot of people think its XML is too voluminous. Spring is a good example of the new frameworks that allow choice. They are platforms rather than monolithic applications. A promising new web framework which uses Java 5 annotations rather than XML is beehive currently in the Apache incubator.

It is a little clear what will happen with JSF. It has been coming for a long time, but only one person in the audience was using it.


Jo Walnes, a colleage of mine, presented SiteMesh. SiteMesh is a layout manager which aims to separate “functional” from “presentation” html. It uses a filter to mesh the two together.

Tuesday Tutorials – Ajax and Mono


This was a very enoyable tour through the fascinating world of AJAX. The letters stand for Asynchronous, JavaScript and XML. For those of you who are not familiar with AJAX, check out Google maps. Asynchroous requests are made outside the main GUI thread you interact with. This approach is how most desktop software works. The user always retains the locus of control. So your browser pages act more like a desktop app.

Of course doing this requires mindbending JavaScript. I personally hate JavaScript for lack of decent tools and consequent difficulty in developing it. DojoToolkit can do the hard bits for you. IntelliJ now supports the editing of JavaScript which also lowers the pain point. I am very keen to do my first AJAX app.


Mono is an open source implementation of C# and the CLR. I have never been able to install Monodevelop on Redhata or Fedora distros. Mono comes from Ximian, now part of Novell. Ximian has always had its own Gnome distribution, and naturally builds Mono on that. Happily you can now download an installer which works. I played with Monodevelop yesterday. It is no IntelliJ but is useable.

Mono plays very well with Linux. It is ridiculously easy to build GUI apps using Glade and Mono. You design in Glade, save it as XML and bind to it at runtime.

iKVM is shortly to be added to the standard Mono distro. It tranlates byte code to intermediate code and vice versa. So you can use Java libraries from Mono and any .Net assemblies from Java. Apparently JBoss, Weblogic and Eclipse all work fine running in the Mono CLR. Under the covers it uses GCJ and Classpath, so the limitations of iKVM are the same.

Monday 1 August – Tutorials Day 1

I went to two tutorials – Ruby with Dave Thomas and an Eclipse Session


This session was well attended by first timers. Dave Thomas whizzed through the language features and then onto some applications of Ruby.

Who needs IDEs?

I spent some time during the session checking out IDEs for Ruby. I played with Arachno Ruby, FreeRide (some guys who write it are there), the Eclipse plugin and some others that needed the Fox GUI toolkit, which I could not install. They all seem a bit raw to me. The Eclipse plugin is promising but gives errors.

Dave Thomas uses a text editor. He is disparaging of the whole idea of an IDE. Indeed he was disparaging of the need of any feature not currently available in Ruby. Guido Van Rossum, the Python guy, has a similar attitude. Having bought Dave’s book, I also discovered irb, the interactive ruby shell.

Ruby on Linux

Ruby on Linux seems to be in an interesting state. The yum install for Fedora Core 4 does not work properly. I eventually downloaded and compiled the source. I then needed to reinstall RubyGems to get it all working. With that done it was easy to go to RubyForge and get some other stuff like ActiveRecord. Dave uses a Mac.

The Dynamic Language Wars

During the session Dave made a few criticisms of Python and Perl. At a session given by Guido at PARC in January he criticised Ruby. It seems to me that the dynamic languages are competing for hearts and minds.

Ruby seems to be targeting itself as a general purpose OO language. Rails is seen as a breakthrough in popularising it. Any missing features are glossed over. e.g. In answer to the lack of OS threads in the current Ruby Dave’s answer was “it only matters if you on a multi cpu machine…” to “..use multi process which is better anyway” to finally “it is coming in a future version”. ActiveRecord, which Dave calls a Table abstraction had limitations but “there cannot be more than two days work to make it do what Hibernate does”. Gavin King will have to slap himself for the three years it has taken him to do the original.

So will I use it?

In the end I was sufficiently impressed with Ruby to buy the book and make a committment to learning it. Hopefully I will be able to write a few useful scripts here and there.

Introduction to Eclipse

Bill Dudnin walked us through a tutorial on Eclipse. It sort of became an intro on Java/Advertorial for his company so I did not stay right to the end. (I am learning Ruby instead). However in the break Bill gave me some good answers to some problems I have been having as I have started using the Eclipse Platform.


On Friday afternoon I was working on adding some libraries to an exisitng plugin I set up earlier in the week. All the quick attempts to get it in the classpath failed, including adding it to jre/lib/ext. Very strange. Anyway the explanation is that Eclipse implements the ideas of, including the seemingly strange class loader behaviour.

The Usability problem

I find the Eclipse IDE very unintuitive and frustrating to use. I have seen others have the same problem. Bill assures me that is normal. Suggestion to IBM – do some usability testing, or maybe just try IDEA occasionally.

Mac OS X

The new app we are doing is in Java 5. The eclipse launchers for Windows and Linux seem fine with that. Not the Mac launcher. It wants 1.4.2. I tried hacking its package contents the other night with no success. Bill does not know about 1.5 on Eclipse and neither do I (yet).

More generally Bill said that there is quite a lot of stuff that does not work that well in the Eclipse Platform for the Mac.

The Ant afterthought

The Eclipse project does not use Ant at all, apart from one developer, who does the Ant integration. It shows. Bill suggested that anyone who was Ant centric might consider using Netbeans.

What documentation

So where do you go for documentation on all of these vexing issues? Bill reassured me that there is pretty much no decent documentation out there. In fairness, I found the RCP tutorial part 1 actually worked this time, whereas it was a real struggle the last time I played with it in January. Parts 2 and 3 remain a year out of date and looked too unlikely to work for me to go there.


I see usability and documentation as the two biggest issues with Eclipse and the Eclipse platform. My current project will require me to tame the beast. If I can learn to use Lotus Notes, I can deal with any lack of usability.

Sunday 31 July

OSCON seems to have serendipitously coincided with a beer festival on down at the river here in Portland. I am awaiting the arrival of Paul Hammant and Jo Walnes, at which time I will have a few pots. (Queensland speak). I spent the afternoon tacking down and squashing an elusive timing bug in ehcache-constructs AsynchronousCommandExecutor , an asychronous, fault tolerant, VM restart tolerant implementation of the Command pattern.

It is a hot steamy day here in Portland. Every street corner in the downtown is occupied by suspicious looking characters who approach you seemingly to panhandle, only at the last instant they don’t. It was been explained to me by the local Peet’s Coffee that these are drug dealers. Apparently they are mostly harmless. However because of the threat they will shoot up in the toilets, in the last decase all of the coffee shops closed their restrooms.

Tomorrow I am hoping for some other valuable insights into Ruby (Dave Thomas) and Eclipse (Bill Dudney). I have been working on a cross-plaform Eclipse Platform 3.1 app the last few weeks. I find it greatly improved over 3.0, however the plugin classloader appears to be incomprehensible. Sadly, the Mac launcher is 1.4.2 only, and I have not yet figured out how to launch JDK1.5 apps with it, although they work fine on Linux and that other very non open source OS.

Update 7:02pmPaul Hammant is here. I can taste the beer.