Proof of Concept: GWT, Restlet, OSGi and Maven

After some difficulties I got a project working, which consists of a simple GWT application with a Restlet backend. The application consists of four OSGi bundles, which work inside eclipse PDE. Also, all of these modules and their dependencies are declared using Maven 2.


The user interface is based on google‘s standard project from the google eclipse plugin.

The button Ping triggers a very simple REST call to the server (based on example from Restlet documentation)

tstBtn.addClickHandler(new ClickHandler() {

                        public void onClick(ClickEvent event) {
                         ClientResource r = new ClientResource(“/ping”);

                         r.setOnResponse(new Uniform() {
                         public void handle(Request request, Response response) {
                         try {
                         } catch (IOException e) {

Clicking this button should result in the caption of the button being filled with a response from the server.

The server resource is as following:

public class PingResource extends ServerResource {

public String toText() {
StringBuilder sb = new StringBuilder(“Restlet server alive. Method: “);

ChallengeResponse challengeResponse = getRequest()
if (challengeResponse != null) {
sb.append(“/ Auth. scheme: “);

return sb.toString();

The send button should work in the same way as in the google example; only that the remote procedure call is facilitated using Restlet.


GWT Client:

GreetingServiceAsync r = GWT.create(GreetingServiceAsync.class);
                                r.greetServer(new Name(nameField.getText()), new AsyncCallback<String>() {

                                        public void onFailure(Throwable caught) {
                                                // Show the RPC error message to the user
                                                                .setText(“Remote Procedure Call – Failure”);

                                        public void onSuccess(String result) {
                                                dialogBox.setText(“Remote Procedure Call”);

Restlet Server:

public class GreetingServiceServerResource extends ServerResource implements GreetingService {

        public Representation handle() {
                 CompositeClassLoader customCL =
new CompositeClassLoader();
                 ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
                Representation rep =
return rep;

        public String greetServer(Name name) throws IllegalArgumentException {
out.println(“Name submitted: “;
return “Welcome “” from Restlet!”;


OSGi Bundles:

Under equinox, the following modules were required:

id        State Bundle
0        ACTIVE org.eclipse.osgi_3.5.2.R35x_v20100126
         Fragments=2, 3
2        RESOLVED org.eclipse.persistence.jpa.equinox.weaving_1.1.3.v20091002-r5404
3        RESOLVED javax.transaction_1.1.1.v201002111330
17        ACTIVE org.hamcrest.core_1.1.0.v20090501071000
18        ACTIVE thrdGWTUser_0.0.2.SNAPSHOT
19        ACTIVE javax.servlet_2.5.0.v200806031605
21        ACTIVE org.junit4_4.5.0.v20090824
41        ACTIVE org.eclipse.osgi.services_3.2.0.v20090520-1800
49        ACTIVE thrdRestletGWT_0.0.2
50        ACTIVE thrdRestletExtSimple_0.0.2
51        ACTIVE zzSampleGWTClient_0.0.2
52        ACTIVE zzSampleRestletServer_0.0.2

Lessons Learned and Helpful Resources

– org.restlet.ext.simpleframework is deprecated and should not be used
– the current version for the Maven GWT plugin is 1.3-SNAPSHOT or My projects worked with 1.3-SNAPSHOTS at the end.
– Restlet might have problems with transporting String objects. Therefore I encapsulated the String with the username in a Name object.
Classloaders: GWT RPC, OSGi and Restlet
GWT Module XXX not found in project sources or resources.
CLAP Protocol in Restlet and OSGi
GWT + OSGi + Maven
Restlet Server: OSGi and Maven
Deployment of GWT Applications (Part 2)
Maven, GWT and Eclipse Quick start (Part 1)

12 thoughts on “Proof of Concept: GWT, Restlet, OSGi and Maven

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s