IncompatibleRemoteServiceException при использовании RPC в GWT - PullRequest
0 голосов
/ 21 марта 2012

У меня есть проект веб-приложения с вызовом RPC.

Один 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 );
}
}

} * * тысяча двадцать-один

Не работает 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 спроектированы в одинаковом режиме, но все равно выдает ошибку.

Если кто-нибудь скажет мне, почему это поможет?

спасибо.

Ответы [ 2 ]

2 голосов
/ 21 марта 2012

Ваше сопоставление URL отключено, вам нужно сопоставить ваши RPC RemoteServiceServlets с лучшим url-pattern.Вы отображаете оба сервлета на /*.Нет гарантии, какой сервлет будет выполнен, когда два или более сопоставлены с одинаковыми url-pattern.Поэтому я предполагаю, что каждый раз, когда вы запускаете неработающую службу, вызов сопоставляется с другой службой.

Чтобы решить эту проблему, можно использовать файл web.xml, например

<servlet-mapping>
  <servlet-name>ConnectionServlet</servlet-name>
  <url-pattern>/ConnectionService.rpc</url-pattern>
 </servlet-mapping>
 <servlet-mapping>
   <servlet-name>ObjectStore</servlet-name>
   <url-pattern>/ObjectStoreService.rpc</url-pattern>
 </servlet-mapping>

Конечно, вы также должны изменить свои клиентские сервисы, чтобы использовать правильные serviceEntryPoint, поэтому

 endpoint.setServiceEntryPoint(GWT.getModuleBaseURL() + "rpc");

придется изменить на что-то вроде

 endpoint.setServiceEntryPoint(GWT.getHostPageBaseURL() + "ConnectionService.rpc");

, чтобы получитьк правому сервлету.

РЕДАКТИРОВАТЬ: Ошибка изменения:

ОШИБКА

 @ftr   `com.google.appengine.tools.development.ApiProxyLocalImpl log
SEVERE: javax.servlet.ServletContext log: ConnectionServlet: 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.ConnectionServiceImpl'; 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)

Итак, если вы посмотрите внимательно, ошибка будет другой:

Блокированная попытка доступа к интерфейсу com.client.RepositoryInterface, который не реализован в com.server.ConnectionServiceImplObjectStore '

вместо

Блокированная попытка доступа к интерфейсу com.client.RepositoryInterface, который не реализован com.server.ObjectStore.

Это означает, что ваша конфигурация по-прежнему неверна, вы должны указатьваша клиентская сторона RepositoryInterfaceAsync до RemoteServiceServlet, которая реализует RepositoryInterface.

0 голосов
/ 21 марта 2012

Это может быть неверная конфигурация версии gwt-servlet.jar в вашем веб-контейнере. Проверьте версию gwt-servlet.jar вашей разработки и версию gwt-servlet.jar веб-контейнера. n для справки Неверная конфигурация или попытка взлома

...