Restlet实际上是否适用于GWT 2.4

时间:2012-07-08 08:03:48

标签: google-app-engine gwt restlet

我使用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)

1 个答案:

答案 0 :(得分:1)

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

换句话说:尝试使用更新版本的Restlet;一个针对最近版本的GWT编译的。