我正在尝试让一个非常简单的 gwt-syncproxy 示例在 Eclipse 开发人员模式下工作。我创建了示例 GWT/GAE 项目并将其命名为“testgwtrpc”。我验证了这可以发送问候语并接收服务器的响应。我创建了以下独立 Java 程序来调用 GWT RPC。
SyncProxy.setBaseURL("http://127.0.0.1:8888/testgwtrpc/");
GreetingServiceAsync greetingServiceAsync = SyncProxy.create(GreetingService.class);
greetingServiceAsync.greetServer("Hello", new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(String result) {
System.out.println("From server: " +result);
}
});
}
我从 SyncProxy.setBaseURL()
抛出以下异常:
INFO: No RemoteService in the classpath
Feb 16, 2015 5:10:19 PM com.gdevelop.gwt.syncrpc.SyncProxy populatePolicyMap
INFO: Populating Policy Map
Exception in thread "main" com.gdevelop.gwt.syncrpc.exception.SyncProxyException: Error POLICY_NAME_POPULATION. Unable to populate policy names, see below exception.
at com.gdevelop.gwt.syncrpc.SyncProxy.populatePolicyMap(SyncProxy.java:515)
at com.gdevelop.gwt.syncrpc.SyncProxy.setBaseURL(SyncProxy.java:532)
at com.ptflix.utilities.CallGwtRpc.main(CallGwtRpc.java:12)
Caused by: java.io.FileNotFoundException: http://127.0.0.1:8888/testgwtrpc/compilation-mappings.txt
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1835)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1440)
at com.gdevelop.gwt.syncrpc.RpcPolicyFinder.getResposeText(RpcPolicyFinder.java:201)
at com.gdevelop.gwt.syncrpc.RpcPolicyFinder.fetcherSerializationPolicyNameJS(RpcPolicyFinder.java:68)
at com.gdevelop.gwt.syncrpc.RpcPolicyFinder.fetchSerializationPolicyName(RpcPolicyFinder.java:180)
at com.gdevelop.gwt.syncrpc.SyncProxy.populatePolicyMap(SyncProxy.java:513)
... 2 more
看起来这应该很简单,但是,可惜,它不起作用。
有什么想法吗?非常感谢您的帮助。
最佳答案
检查这个link
Unable to find RPC Policy File GWT-Compile your web-app, make sure your service is running where you expect it to be (deployed vs local testing urls), and if using GAE, make sure to alter your appengine-web.xml as noted in the Android#Setup_in_Eclipse section. Essentially, you need to make sure that the .gwt.rpc files are available to access from the "remote" Android client.
关于java - 无法让 gwt-syncproxy 工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28551494/