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.

24 comments:

Ed Merks said...

Ian,

It's always extremely useful to have a working example as a basis for starting out. The jars have Apache License, so that should be fine.

Doug Schaefer said...

Very cool! Thanks.

Ian Bull said...

Ed, to do this would I have to propose a GWT bundle for Orbit?

lan said...

Unfortunately the link containing the project zip doesn't work!

lan said...

would youlz send the zip file to this adress : (anouar.khemili@gmail.com)
thank you!

rauschma said...

Could one truly have plugins this way that work on the client-side too? The main problem I see is that a plugin could not hand a class to the framework, because in client-side GWT, new instances can only be created directly from class literals (i.e., statically).

lan said...

Great!! The link is working now.
Tkanks

Il vero Capitano said...

ian,

I get a ClassCastException from SimpleServiceImpl when the server is called, what could be the reason?

PD: I quit "Require-Bundle: javax.servlet" from com.google.gwt MANIFEST to avoid nasty classloader, since gwt-user.jar contains the package.

Shady Shrif an Egyptian Software engineer said...

hi ian
the file is down again
please try to upload it
i know that i'm too late but really your try the only success story i found tell now :)

Unknown said...

The link containing the project zip doesn't work.
Would youl send the zip file to my e-mail (bruno.evert@hotmail.com)?
Thanks!

Shady Shrif an Egyptian Software engineer said...

ian,
could you send it to me too
shady.shif@gmail.com

thanks.

PuguaSoft LLC said...

Hi Ian,

Would you please update the link to the source?

Thank you very much!

Ian Bull said...

Hi everyone,
I will track down the download and re-post it. Thanks for letting me know that the link is down.

Shady Shrif an Egyptian Software engineer said...

hi Ian it still doesn't work!!
please man try to upload it ASAP i need it so much.

thanks a lot my friend.

Unknown said...
This comment has been removed by the author.
Unknown said...

Hello!

The link doesn't work again... can you fix it or send me? thnx..

Unknown said...

can please repost sample

Unknown said...
This comment has been removed by the author.
Unknown said...
This comment has been removed by the author.
Unknown said...

Unfortunately the link containing the project zip doesn't work! Would you plz send the zip file to this address : (ehsan2@gmx.de)

thank you!

Diego Cirujano said...

Could you update the zip file link?

Thanks,

Diego

Kris Reid said...

Thanks for the writing the article but please update the link to the zip.

It would really help get this working

Thanks

Bao Anh Huynh said...

Unfortunately the link containing the project zip doesn't work! Would you plz send the zip file to this address : (baoanh4386.it)

paveenju said...

The link containing the project zip doesn't work. Would you please send me the zip file to my address : (paveenju@gmail.com)
thank you!