Friday, September 05, 2008

GWT and OSGi

A number of people have asked me how I configured GWT and OSGi. Some detailed steps are available here, however, following wiki pages is not always the easiest thing. I have created a small "hello, world" example. You can get the projects here.

To use this, simply import the zip file into eclipse: (File->Import, select Existing Projects into Workspace).

Once it is imported, you should have 3 projects in your eclipse workspace:
The GWT project is simply the GWT jars wrapped in a bundle.

The client project is the client side code, and the server project is the servlet we use (it simply returns the word "World" to complete Hello, World.)

I have included an external tool to compile the client side code. Make sure you select com.example.gwtclient ant_build.xml in the external tools list.

After this runs, you should refresh your workspace (press F5). Under the com.example.gwtclient you should have www directory.

Finally, you can use the provided launch configuration to actually launch OSGi, the Jetty engine and the servlets. To do this, go to Run Configurations..., and select GWT Example Launch.

This will launch the Jetty server on port 80. If you want to change this, go to the Arguments tab and set -Dorg.osgi.service.http.port=8080 in the VM arguments.

Once running, simply hit: http://localhost/index.html

If anyone is interested, we could extend this and make it part of the Eclipse Examples project. However, there may be some licensing issues as it currently includes the GWT jars.