Jaimin Shah
Jaimin Shah

Reputation: 271

Error in gwt-rpc

I created a RPC service which created a SportsLeagueAndroidRequest in the appengine shared folder. When I am running to try my project it shows an error

[ERROR] [sportsleagueandroid] - Deferred binding result type 'edu.columbia.sportsleagueandroid.shared.SportsLeagueAndroidRequest' should not be abstract

SportsLeagueAndroidRequest is an interface generated automatically when you create a RPC service!!

How can I remove this error?

final EventBus eventBus = new SimpleEventBus();

final MyRequestFactory requestFactory = GWT.create(SportsLeagueAndroidRequest.class);
requestFactory.initialize(eventBus);

sendMessageButton.addClickHandler(new ClickHandler() 
{
public void onClick(ClickEvent event) 
{
    //String recipient = recipientArea.getValue();
    //String receivers[] = recipient.split(",");
    String message = messageArea.getValue();
   // setStatus("Connecting...", false);
    sendMessageButton.setEnabled(false);
    sendNewTaskToServer(message);
}
private void sendNewTaskToServer(String message) {
    SportsLeagueAndroidRequest request = requestFactory.sportsLeagueAndroidRequest();
    StadiumProxy task = request.create(StadiumProxy.class);

Upvotes: 1

Views: 141

Answers (1)

Travis Webb
Travis Webb

Reputation: 15018

final MyRequestFactory requestFactory = GWT.create(SportsLeagueAndroidRequest.class);

You are invoking GWT.create on a RequestContext. It needs to be invoked on a RequestFactory as explained here.

You need to create an interface that extends RequestFactory as in the example I linked to. If you look in your sendNewTaskToServer method, you are actually calling sportsLeagueAndroidRequest() from SportsLeagueAndroidRequest. See? You should be calling sportsLeagueAndroidRequest() from your RequestFactory interface that you previously created with GWT.create.

The RequestFactory lifecycle looks something like this:

  1. Create a new RequestFactory using GWT.create(MyRequestFactory.class)
  2. Create a RequestContext using myRequestFactory.myRequestContext()
  3. Fire a request, using myRequestContext().myDomainMethod().fire()

Upvotes: 1

Related Questions