0

我有一个使用 Objectify 在 Google App Engine 上运行的后端,并已开始尝试向其添加 REST Web 服务。我只读过关于 Restlet 的好东西,所以我决定从那里开始——我查看了第一个应用程序示例并完成了它——设置了所有内容,最后我在客户端遇到了以下问题:

private final UserResourceProxy userResourceProxy = GWT.create(UserResourceProxy.class);

其中 UserResourceProxy 如下

import org.restlet.client.resource.ClientProxy;
import org.restlet.client.resource.Delete;
import org.restlet.client.resource.Get;
import org.restlet.client.resource.Put;
import org.restlet.client.resource.Result;

import com.exposure101.lifelogger.shared.entity.User;

public interface UserResourceProxy extends ClientProxy {

  @Get
  public void find(String emailAddress, Result<User> callback);

  @Put
  public void persist(User user, Result<User> callback);

  @Delete
  public void delete(Result<Void> callback);
}

这是我得到的堆栈跟踪 - 似乎它不知道如何在 GWT 2.4 中创建 ClientProxy

java.lang.RuntimeException: Deferred binding failed for 'com.exposure101.lifelogger.client.rest.proxy.UserResourceProxy' (did you forget to inherit a required module?)
  at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:53)
  at com.google.gwt.core.client.GWT.create(GWT.java:97)
  at com.exposure101.lifelogger.client.App.<init>(App.java:20)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
  at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:465)
  at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:375)
  at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
  at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
  at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
  at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IncompatibleClassChangeError: Found interface com.google.gwt.core.ext.typeinfo.JClassType, but class was expected
  at org.restlet.rebind.ClientProxyGenerator.generate(ClientProxyGenerator.java:239)
  at com.google.gwt.core.ext.GeneratorExtWrapper.generate(GeneratorExtWrapper.java:48)
  at com.google.gwt.core.ext.GeneratorExtWrapper.generateIncrementally(GeneratorExtWrapper.java:60)
  at com.google.gwt.dev.javac.StandardGeneratorContext.runGeneratorIncrementally(StandardGeneratorContext.java:647)
  at com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:41)
  at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:78)
  at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:268)
  at com.google.gwt.dev.shell.ShellModuleSpaceHost.rebind(ShellModuleSpaceHost.java:141)
  at com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:585)
  at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:455)
  at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:49)
  at com.google.gwt.core.client.GWT.create(GWT.java:97)
  at com.exposure101.lifelogger.client.App.<init>(App.java:20)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
  at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:465)
  at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:375)
  at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
  at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
  at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
  at java.lang.Thread.run(Thread.java:662)
4

1 回答 1

1

此错误通常意味着您正在使用针对 GWT 2.1 或更早版本和 GWT 2.2 或更高版本编译的库:GWT 2.2 引入了二进制不兼容性。不过,没有源级别的重大更改,因此针对 GWT 2.2 重新编译第三方库足以使其与 GWT 2.2 或更高版本一起使用。

In other words: try using a more recent version of Restlet; one that has been compiled against a recent version of GWT.

于 2012-07-08T11:05:45.947 回答