gwt-syncproxy can't connect to the address - gwt

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)

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:
Is the Development Mode host running in eclipse (Checkout the Development Mode view available in Eclipse) without error?
Are there any errors being thrown by the compiling front-end (check the Console view)
Try clearing your browser cache (brief google search on that error yielded some random occurences preventing the dev mode system from latching on properly)
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.

Related

Can two version of resteasy & jetty be loaded in same JVM

I have a very typical problem. I am using in-house developed platform which uses Jetty server and rest easy to provide a wrapper over REST framework. When they did that they made lot of tweaks for some specific scenes.
Now problem is that when I developed a REST based service with raw interfaces of rest easy and embed my jetty server in same JVM. My service can receive the request but response is always 500 server error.
I feel the in-house framework is intercepting the response doing some security validations so my response doesn't reach.
I was wondering if there is a way to use the different rest easy version and run in same JVM. I have tried to embed a jetty server and added a normal Servlet and I can access it but I can't achieve the same with my rest based servlet.
Any Idea how could I load two versions of rest easy on same JVM ?
What you can't have is two applications in the same web application context, since you are supposed to define only one class implementing javax.ws.rs.Application.
But that shouldn't be a problem, as long as classes live in different ClassLoaders. Each web application context must be in isolation of other contexts, each defining its own ClassLoader.
You can perform all kinds of class loading manipulation in Jetty: https://wiki.eclipse.org/Jetty/Reference/Jetty_Classloading
In conclusion, as long as you use different jar files of RESTEasy in each web context, you should be able to run two REST applications using different RESTEasy versions in the same JVM process.

why server is required for running swt application in Scout

I am new to eclipse scout. I create my first scount hello world application for swt . It automatically created
the server project as well. But when I try to run the swt application, I got the error saying that server
has to start first. Why does server has to run in order to swt client application? Request you to explain the
concept of server here.
RAP is an acronym for Remote Application Platform--the server needs to run for there to be a Remote.
Out-of-the-box, scout applications are designed to be client-server applications. The architecture looks like this:
Your application is the blue part. As developer you focus on your business logic and you rely on the scout framework (orange part) and on the eclipse/equinox stack for common features. Eclipse Scout provides a client server communication mechanism (read more on the architecture of Scout on the eclipse wiki)
Because typical applications look like this, Scout SDK makes the assumption that you want to create a client-server application. When you create a new scout project the client code contains code that induces a server call. If this is not your intention, it is possible to create a client only application with eclipse scout.

GWT and Google Eclipse Plugin: is it possible to run the server in a separate JVM?

I have a GWT project that contains both the GWT UI and the server backend. The server backend contains the Java GWT Services that are exposed via GWT's RPC to the UI.
Since the project has grown quite a bit, with the backend requiring more and more time to start, I am considering moving the UI to a separate project, with the idea to run the backend in a separate VM. The backend is relatively stable, and it is the UI where we spent most time. With the two in separate VMs, we could work on the UI much more efficiently, since we would only reload the UI (in GWT development mode) and leave the backend running.
My question: Is it possible to configure the Google Eclipse Plugin in such a way that it runs the UI and backend in separate VMs and I can still use the GWT development mode?
The project uses GWT 2.4 and we will update to 2.5 as soon as it is out. We use Maven as the build system.
There are two things to consider:
You don't always have to reload the server - usually it's enough to just reload the browser page [*] For an overview of when to reload/restart, ... please see https://stackoverflow.com/a/6150736/291741
You can deploy to an external server. In an Eclipse Run Configuration, go to the Server tab, and uncheck "Run built-in server". This will disable the web server (default port 8888), but will still run the Code Server (default port 9997, see the GWT tab). Then just run your external server (e.g. Tomcat) on port 8888. It should serve the web content, and handle the servlet requests.
If you want to create a really cool fully automated Eclipse-JavaEE + GWT setup, with separate server-side redeploy on any server you like (even with two debugger instances, if you want), see https://stackoverflow.com/a/11700678/291741
[*] I know, there are certain situations, e.g. when changing Gin configuration or Validation annotations, where reloading the web page is unfortunately not enough. But in most cases it just works fine (as long as you run DevMode with "Run As...", not with "Debug As...") If you want to run with a debugger attached, then I'd recommend the external server solution, of course.

GWT - split client and server to different machines

Our lab has a single machine that is open to http connections from outside. However, this machine is quite weak (little memory, slow CPU). We have other machines that are much stronger, but they are behind a firewall and cannot be accessed from outside the lab.
I am writing a GWT app whose server is very demanding. Is it possible to install the server on a strong computer, and the client on the weak compuer, and have them connect using RPC? I assume it requires some changes in the web.xml file, but what exactly?
Theoretically I can just wrap the demanding part in a separate TCP/IP server, and have the GWT server contact it, but I would like to know if it is possible to do directly in GWT.
The GWT client is downloaded from the server and runs inside a Web browser as javascript code. I don't quite understand what part of the GWT app you would want to run on a separate server.
If your GWT servlet (the RPC service implementation) is accessing external resources, like a database or Web services, you could move those resources to a separate server.
Another option is to install a reverse proxy on the "weak" server that would forward specific requests to a stronger server behind the firewall. The proxying could be done by Apache (httpd) on the "weak" server (using mod_proxy). Then Tomcat would only need to be installed on the stronger machine, and would take care of most of the processing.
I have tried to do this but was only successful in splitting a GWT project into 3 parts (Client, RPC, Server) as eclipse projects. In the end you are going to end up with 1 big WAR file and it'll be deployed in one place (unless someone else was successful at really separating the code.)
A solution you can do is to set up another server that will do all the server side processing (your strong machine) and have the GWT servlets act like a proxy. They accept the requests from the client and forward the data to another server for processing. Then wait for the response.
How you do it is up to you. You could use web-services, direct socket connection, JMS ..etc.
Depends on your setup.
GWT ACRIS- Please see this link.
EJB - One approach could be to keep business objects in remote machines as EJBs and your servlets accessing them over RMI/JNDI.
Spring - Another simple way to do it is with Spring Remoting. See this link.

GWT server part?

I'm thinking about an application where in some cases both client and server would run on customer's computer. Concerning the client's resource usage I've found this question, concerning the general disadvantages of GWT I've found this, but I can't find anything about the overhead of the server part. I need no application server there, anything capable of running the server part of GWT would do.
What is needed to run the server part of GWT and how many resources it consumes?
If you use a ServiceImpl w/ your GWT app, you need to deploy it into a servlet container, like Tomcat or Jetty (or many others). Otherwise, it can be deployed on any web server, as it will only consist of javascript, HTML, and CSS.