我有Web应用程序项目有RPC调用。在GWT中使用RPC时IncompatibleRemoteServiceException
一个RPC异步工作正常。但另一个给人一种错误
Mar 21, 2012 1:34:51 PM com.google.appengine.tools.development.ApiProxyLocalImpl log
SEVERE: javax.servlet.ServletContext log: ObjectStore: An IncompatibleRemoteServiceException was thrown while processing this call.
com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException: This application is out of date, please click the refresh button on your browser. (Blocked attempt to access interface 'com.client.RepositoryInterface', which is not implemented by 'com.server.ObjectStore'; this is either misconfiguration or a hack attempt)
at com.google.gwt.user.server.rpc.RPC.decodeRequest(RPC.java:252)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:206)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
工作RPC
public interface ConnectionInterface extends RemoteService{
String connection(String[] authentication);
}
public interface ConnectionInterfaceAsync {
void connection(String[] authentication, AsyncCallback<String> callback);
}
公共类ConnectionService实现ConnectionInterfaceAsync {
ConnectionInterfaceAsync service = (ConnectionInterfaceAsync)GWT.create(ConnectionInterface.class);
ServiceDefTarget endpoint = (ServiceDefTarget) service;
public ConnectionService() {
endpoint.setServiceEntryPoint(GWT.getModuleBaseURL() + "rpc");
}
public void connectionCMIS(String[] authentication,
AsyncCallback<String> callbackConnection) {
service.connectionCMIS(authentication, callbackConnection);
}
//客户呼叫
public class Login extends Composite {
private ConnectionService connectionService = new ConnectionService();
// more code
public void onClick(ClickEvent event) {
AsyncCallback<String> callbackConnection = new AsyncCallback<String>() {
public void onSuccess(String result) {
// print Succuss
}
}
connectionService.connection(authentication, callbackConnection);
}
}
}
不Workink RPC
public interface RepositoryInterface extends RemoteService {
public FolderCollection getRepositories();
}
public interface RepositoryInterfaceAsync {
void getRepositories(AsyncCallback<FolderCollection> repositoryCallback);
}
public class RepositoryService implements RepositoryInterfaceAsync{
RepositoryInterfaceAsync async = (RepositoryInterfaceAsync)GWT.create(RepositoryInterface.class);
ServiceDefTarget endpoint = (ServiceDefTarget) async;
public CmisRepositoryService() {
endpoint.setServiceEntryPoint(GWT.getModuleBaseURL() + "repository");
}
public void getRepositories(
AsyncCallback<FolderCollection> repositoryCallback) {
async.getRepositories(repositoryCallback);
}
}
客户端调用
public class Workplace {
private RepositoryService service = new RepositoryService();
// some more code
void doRepo(){
AsyncCallback<FolderCollection> repositoryCallback = new AsyncCallback<FolderCollection>() {
public void onSuccess(FolderCollection result) {
}
public void onFailure(Throwable caught) {
}
};
service.getRepositories(repositoryCallback);
}
}
XML代码
<servlet>
<servlet-name>ConnectionServlet</servlet-name>
<servlet-class>com.server.ConnectionServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>ObjectStore</servlet-name>
<servlet-class>com.server.ObjectStore</servlet-class>
<servlet-mapping>
<servlet-name>ConnectionServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ObjectStore</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
两个RPC设计在同类图案还是它给了我一个错误。
如果有人能告诉我为什么会很好帮助
谢谢。
仍然我收到相同的错误。我正在更新您的代码中的错误。 – GameBuilder 2012-03-21 13:42:27
@GameBuilder你有另外一个实现'com.server.ObjectStore'的服务吗?我只是意识到你对'RepositoryInterface'的请求实际上映射到了那个。我仍然认为这是您的web.xml /服务入口点配置错误的情况。 – ftr 2012-03-21 13:53:31
不,只有一个使用'com.server.ObjectStore'的服务。但其他服务使用'com.server.ConnectionServiceImpl'和'objectStore extends ConnectionServiceImpl' – GameBuilder 2012-03-21 14:01:33