vartika vartika - 3 months ago 45x
Java Question

GWT- How to make RPC call(use server side) of one project in some other project?

We have created our web project on GWT with java. Totally working fine. Now, we are moving towards making the version of website for mobile which will also be on gwt and will be having a different url for sure(like


We want to use the server side of our web project as server side of
the mobile website. So that only front-end have to be changes. As gone
through some tutorials got that its possible that gwt rpc call made
from android app.

But we want that it should be possible in gwt to gwt RPC call.

For android app they use Syncproxy where they change the baseurl and
use it to call the gwt server side methods. It will be for sure the
reusability of the code.



GreetingServiceAsync greetService = SyncProxy.create(GreetingService.class);

So, How to achieve it for GWT project to use server side methods of other project throuhg this method?

NEW ISSUE :The import com.gdevelop cannot be resolved

I had gone through more of docs of gwt for the cross domain rpc calls like gwt to android app. I got the syncproxy 0.5 jar file, which is exactly the same as one for android. Having the same functions. I imported the jar file in the project and called for the functions of SyncProxy as follow.

public void onModuleLoad() {

final GreetingServiceAsync greetService = SyncProxy.create(GreetingService.class);

final Button sendButton = new Button("Send");
final TextBox nameField = new TextBox();
nameField.setText("GWT User");
final Label errorLabel = new Label();

// We can add style names to widgets

// Add the nameField and sendButton to the RootPanel
// Use RootPanel.get() to get the entire body element


Now while compiling the project i am getting the following errors.error

EDIT 2:-

How to implement CORS filter in tomcat for Cross domain request?


try setting the service Entry Point in your child project
((ServiceDefTarget) greetService).setServiceEntryPoint("");

if your childproject is deployed withtin another domain you may need a CORS filter to allow cross site requests

How to set up a simple exampel:

  1. Create a "New Web Application project..." and select "generate project sample code" and name it "mobileapp"
  2. Create another "New Web Application project..." and select "generate project sample code" and name it "webapp"
  3. in the copy this code in the first line of onModuleLoad: ((ServiceDefTarget) greetingService).setServiceEntryPoint(""); webapp/greet is the <url-pattern>/webapp/greet</url-pattern>from your web.xml. is the URL to your webapp
  4. Compile both applications and deploy them on the same tomcat instance. if you deploy them on different tomcats you have to use a CORS filter for your webapp and allow cross domain requests.
  5. open in your browser and press the Send button. It will use the Server method of your webapp
    Important: This only works if both GreetingService interfaces have the same methods... so always keep them in sync

here you can download the two projects, as described above on your own risk: googledrive link