Technology exploration: Vaadin and jMonkeyEngine applet?

We’re getting excited over here about the possibilities of deploying the Whole Brain Catalog in a completely different way.  I’ve decided to start exploring these possibilities to see if the technologies we are looking at could bear fruit.  This may be a dead end, but its always fun to play with new tools!

The first thing that has gotten us excited is the discovery of a technology called Vaadin.  Vaadin lets you write user interface code in Java only and then it magically converts that user interface into a web application written in JavaScript.  If you are familiar with the Google Web Toolkit (GWT), this will sound familiar.  However, it appears that Vaadin has some significant advantages over GWT.  The ones we are interested in are the running of the client code on the server.  This would eliminate the need for WBC users to download a ~50 mb webstart package.  Also, regular GWT doesn’t allow the usage of any arbitrary Java libraries, which Vaadin apparently does.

Vaadin only handles 2D interfaces though, so the puzzle is to try to get a workable 3D interface involved as well.  After a lot of investigation into the next generation 3D-in-a-browser solutions that are being put forward, it seems clear that there is still a long way to go before there is a clearly better technology for WBC than jMonkeyEngine.  The advantage of switching to Vaadin, however, would be to deploy the 3D view as a much smaller lighter-weight java applet.  The 2D interface would load up immediately as the user arrived at the web page, and would make waiting for the applet to load much friendlier.

The rest of this post will be devoted to my exploration trying to get Vaadin to work with a jMonkeyEngine applet.

The first step was to locate the Vaadin eclipse plugin and initial tutorial.  The only gotcha here was to install a local copy of Tomcat and tell eclipse about it, which I found out how to do on a different page after some googling (seriously, how did anyone develop anything before google?).

I ran the initial tutorial class (the address book) by replacing the code in the HelloWorld example.  The address book example came up in my browser quite nicely and impressed me with how concisely a web app could be expressed.

Working Vaadin address book tutorial

Working Vaadin address book tutorial

The next link is how to get a java applet — any java applet, to work with this framework.  Since Vaadin integrates GWT widgets, and a GWT widget wrapping java applets exists, I decided to take the approach of first getting a regular GWT widget example in Vaadin to work.

Happily, on the Vaadin page I found an example of a GWT widget integrated with the framework that integrates Google Maps.  In order to get a hold of it, I downloaded it from SVN, figuring that I could permute the URL for the page I was pointed to to get at the SVN repository, and found that http://dev.vaadin.com/svn/incubator was the right repository to put into eclipse to find the source.

Once I had checked out the source into a new eclipse project, I tried to run it right away by doing the “run on server” command with the MapWidgetApp class selected.  Navigating to http://localhost/MapWidget/ gave me a blank page the first time, so I had to figure out that I needed to run the two Ant scripts: build.xml and build-widgetsets.xml and refresh the eclipse directory before the app would work.  Once I did that, it came right up:

Successful run of the Vaadin GWT MapWidget

Successful run of the Vaadin GWT MapWidget

The next challenge was to substitute the Google Maps GWT widget with the GWT applet integration library.  Back to SVN to check out the GWT-AI demo at http://gwtai.googlecode.com/svn/trunk/.  I tried running the build.xml Ant script, but got build problems.  I noticed that a variable named gwt.dir was set to a directory that didn’t exist on my machine, and that the build problems suggested that GWT was missing.  So, I installed the GWT plugin to eclipse.  This caused my eclipse installation to be unhappy, so while I was waiting for eclipse to restart, I started nosing around the Vaadin book, and found a relevant chapter on GWT widget integration.

Once eclipse restarted, it seems that nothing I do makes the GWT-AI demo happy.  I’m using GWT 2.0.1 and Java 6, but I’m getting failures related to “[ERROR] Failed to link”.  I started nosing around the FAQ and forums, and found that this plugin hasn’t been extremely well maintained.  Several are reporting problems related to compilation with Java 6.  One post looks promising, describing a way to do GWT applet integration without using this library at all!  Unfortunately that’s all the time I have for tonight.  One thing that I’m going to have to follow up on later is the possibility of a context menu that will work across these two technologies.

Will I be able to figure out how to merge these two great technologies?  Stay tuned!

Leave a Reply