I want to perform simple unit tests in Java for my server using GWT-RPC.
I have created a GWT project (GWT 2.7) in Eclipse (with the default GreetingService). It works and I can start it as a servlet in a Tomcat server.
Next I have created an Eclipse project to call the GreetingService using syncProxy.
try {
SyncProxy.setBaseURL("http://127.0.0.1:8080/mywebapp/mywebapp/");
GreetingService svc = SyncProxy.createSync(GreetingService.class);
String greeting = svc.greetServer("Hello");
System.out.println("Result: " +greeting);
}
catch ( Exception e )
{
throw new RuntimeException ( e );
}
When I execute this code I get the following exception:
juin 08, 2015 8:57:14 AM com.gdevelop.gwt.syncrpc.RpcPolicyFinder searchPolicyFileInClassPath
Infos: No RemoteService in the classpath
juin 08, 2015 8:57:14 AM com.gdevelop.gwt.syncrpc.SyncProxy populatePolicyMap
Infos: Populating Policy Map
juin 08, 2015 8:57:14 AM com.gdevelop.gwt.syncrpc.RpcPolicyFinder fetcherSerializationPolicyNameJS
Infos: Remote Services found with JS Fetcher
juin 08, 2015 8:57:14 AM com.gdevelop.gwt.syncrpc.SyncProxy defaultUnsetSettings
Infos: Updating Default Settings for Unset Values
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/MethodNotSupportedException
at com.gdevelop.gwt.syncrpc.SyncProxy.createProxy(SyncProxy.java:120)
at com.gdevelop.gwt.syncrpc.SyncProxy.createSync(SyncProxy.java:138)
at myJmeterPlugin.TestGWT.main(TestGWT.java:11)
Caused by: java.lang.ClassNotFoundException: org.apache.http.MethodNotSupportedException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more
In the class path I have the .jars files from the GWT Project, syncProxy and gwt-servlet.jar.
Do you have an idea how to solve this issue? Regards,
Sébastien.