Question

i'm writing a java project in GWT in eclipse of a car rental agency . I need to trade info between 2 agencies(server), like the lists of the cars available for rent , and i got suggested to use the gwt-syncproxy . Description from the site:

GWT SyncProxy provides synchronous RPC between Java client and RemoteService servlet. By using SyncProxy, we can invoke the GWT RemoteService methods from pure Java (no JSNI) code.

I've followed the official guide(also the only one on the net) https://code.google.com/p/gwt-syncproxy/ but it doesn't work: a message in the browser says:

Plugin failed to connect to Development Mode server at 127.0.0.1:9997 Follow the underlying troubleshooting instructions

(the address i've specified in java client code) project.java

  //create new proxy instance for the service interface:
  private static GreetingService rpcService =
       SyncProxy.newProxyInstance(GreetingService.class,
         "http://127.0.0.1:9997", "greet");

  //invoke the RPC method:
   String result = rpcService.greetServer("SyncProxy");

This is GreetingService.java:

  @RemoteServiceRelativePath("greet")
      public interface GreetingService extends RemoteService {
        String greetServer(String name);
   }

and the service implementation GreetingServiceImpl.java:

  public class GreetingServiceImpl extends RemoteServiceServlet
  implements GreetingService {
    public String greetServer(String name) {
     return "Hello, " + name;
    }
  }

What am i doing wrong? Is there a better way to get to do RPC in lan between different servers? (i got no error in the log file and eclipse console)

Was it helpful?

Solution

Disclaimer: I'm a developer for the Sync-Proxy Android library.

The error you are receiving is not actually from the gwt-syncproxy library. It is from the GWT development system that is indicating that the browser isn't able to contact the dev mode system (being hosted by Eclipse). A couple things to verify:

  1. Is the Development Mode host running in eclipse (Checkout the Development Mode view available in Eclipse) without error?
  2. Are there any errors being thrown by the compiling front-end (check the Console view)
  3. Try clearing your browser cache (brief google search on that error yielded some random occurences preventing the dev mode system from latching on properly)
  4. Try browsing to the hosting url without dev mode support (IE without navigate in the browser to 127.0.0.1:8888 or wherever eclipse says it's hosting your app) and verify that your page is loading properly. If not, I recommend creating a clean start GWT-project and verifying that is working to make sure there isn't another service on your computer that is blocking)

As a follow-up, I'm a little confused by your setup. Are you developing a GWT front-end client or a Java desktop client? Sync-proxy was developed so that regular clients (outside of the GWT framework) could work with GWT designed backended RPC's. Specifically, the server-based RemoteService servlet's need to be utliizing the GWT RPC system, as opposed to just regular RemoteService servlets. If you are developing a GWT front-end client, you should have no need for syncproxy because the regular GWT framework can communicate to the RPC backends. Now, if I understand your purposes of multi-server communication, the question then becomes are you trying to do this communication from your web-frontend (the GWT client) or is this being done from a Java servlet on your backend?

If this is being done in the front-end, I'm afraid I have no instructions available for you to utilize on that because you would have to get past the cross-site scripting issue and syncproxy is not designed to work inside a GWT frontend client (that I've tested anyway). If this is your intention, then as a start, you'll need to use the Asynchronous method call to newProxyInstance:

private static GreetingServiceAsync rpcServiceAsync =
  SyncProxy.newProxyInstance(GreetingServiceAsync.class,
        "127.0.0.1:8888", "greet");

Specifically, you would end up calling this method twice in order to get to targets, where each URL would represent a different rental agency server. Now, hosting that on your dev machine so that it works properly is a bit outside the scope of this answer, but you'll need to take that into consideration as well

If you are doing this on the back-end, syncproxy may (untested) be able to perform your needs, but you'll need to manage for timeout scenarios since the call you are making will not be asynchronous. On top of that, you'll again have to setup different hosting servers in your dev environment to test a scenario where that might be possible. If this is a big need, put in an issue request for the gwt-syncproxy project and I might be able to test out that scenario and provide instructions somwhere down the line.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top