2012-03-21 76 views
0

我有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设计在同类图案还是它给了我一个错误。

如果有人能告诉我为什么会很好帮助

谢谢。

回答

2

您的URL映射已关闭,您需要将RPC RemoteServiceServlets映射到更好的url-pattern。您将两个servlet映射到/*。当两个或多个映射到完全相同的url-pattern时,不能保证哪个Servlet被执行。所以我的猜测是,每次执行不工作的服务时,该调用都映射到其他服务。

工作这一点是使用一个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"); 

,以获得正确的servlet。

编辑:修改的错误:

错误

@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指向执行RepositoryInterfaceRemoteServiceServlet

+0

仍然我收到相同的错误。我正在更新您的代码中的错误。 – GameBuilder 2012-03-21 13:42:27

+0

@GameBuilder你有另外一个实现'com.server.ObjectStore'的服务吗?我只是意识到你对'RepositoryInterface'的请求实际上映射到了那个。我仍然认为这是您的web.xml /服务入口点配置错误的情况。 – ftr 2012-03-21 13:53:31

+0

不,只有一个使用'com.server.ObjectStore'的服务。但其他服务使用'com.server.ConnectionServiceImpl'和'objectStore extends ConnectionServiceImpl' – GameBuilder 2012-03-21 14:01:33

0

这可能是您的web-container上的gwt-servlet.jar版本配置错误。请检查您的开发gwt-servlet.jar版本和web容器gwt-servlet.jar版本。 n供参考 Misconfiguration or hack attempt