GWT RequestFactory:获取“没有令牌类型...”例外

发布于 2025-01-06 13:15:28 字数 1226 浏览 0 评论 0原文

我是 GWT 和 RequestFactory 的新手,因此我正在使用用于 RPC 的 GWT RequestFactory 和用于 ORM 的 Objectify 编写一个简单的测试应用程序。

我有一个简单的 Person 实体,并且能够使所有 CRUD 操作正常工作。我想尝试添加一个值类型,用于将地址存储为 Person 类中的 @Embedded 属性,就像 Google Developer 网站上显示的那样。因此,我添加了一个简单的 POJO 地址、扩展 ValueProxy 的 AddressProxy 等。

我最终在 RequestFactory 调用中添加了几行代码,如下所示:

PersonRequest req = rf.personRequest();
AddressProxy address = req.create(AddressProxy.class);  // Added this
address.setCity(city);                                  // this
PersonProxy person = req.create(PersonProxy.class);
person.setName("Joe");
person.setPhone("215-555-1212");
person.setAddress(address);                             // and this.
req.save(person).fire();

因此,一切都可以完美编译,并单步执行代码,在客户端一切都正常。在服务器端,我得到 UnexpectedExcpetion: No type for token...

具体来说,它似乎在 com.google.web.bindery.requestfactory.server.ResolverServiceLayer 下被这个方法捕获:

@Override
public Class<? extends BaseProxy> resolveClass(String typeToken) {
  String deobfuscated = deobfuscator.getTypeFromToken(typeToken);
  if (deobfuscated == null) {
    die(null, "No type for token %s", typeToken);
  }

我假设它正在尝试确定从请求上下文中输入,但这并不能帮助我了解我到底缺少什么。什么会导致这种情况呢?

I'm new to GWT and RequestFactory so I'm coding a simple test app using GWT RequestFactory for RPC and Objectify for ORM.

I have a simple Person entity and was able to get all crud operations working fine. I wanted to try adding a value type for storing addresses as an @Embedded property in my Person class, just like it's shown on the Google Developer site. So I added a simple POJO Address, AddressProxy extending ValueProxy, etc.

I end up having adding a couple of lines of code to my RequestFactory call like this:

PersonRequest req = rf.personRequest();
AddressProxy address = req.create(AddressProxy.class);  // Added this
address.setCity(city);                                  // this
PersonProxy person = req.create(PersonProxy.class);
person.setName("Joe");
person.setPhone("215-555-1212");
person.setAddress(address);                             // and this.
req.save(person).fire();

So everything compiles perfectly and stepping through the code everything is A-OK on client side. On the server side, I get UnexpectedExcpetion: No type for token...

Spefically it seems to get caught on this method here under com.google.web.bindery.requestfactory.server.ResolverServiceLayer:

@Override
public Class<? extends BaseProxy> resolveClass(String typeToken) {
  String deobfuscated = deobfuscator.getTypeFromToken(typeToken);
  if (deobfuscated == null) {
    die(null, "No type for token %s", typeToken);
  }

I'm assuming it's trying to determine the type from the request context but it's not helping me see what is missing on my end. What would cause this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

誰ツ都不明白 2025-01-13 13:15:28

您可能缺少所需的 with()

尝试类似 req.save(person).with("address").fire();

You're probably missing the needed with().

Try something like req.save(person).with("address").fire();

吲‖鸣 2025-01-13 13:15:28

这篇文章来自 Google 网络工具包谷歌集团解决了这个问题。这是一个引用:

Eclipse 中的注释处理几乎无法使用。我昨天奋战了几个小时才让它刷新生成的 DeobfuscatorBuilder。 IIRC,我在 eclipse 中刷新项目,然后重新启动它,然后禁用注释处理,删除 .apt_ generated 文件夹并重新启用注释处理。如果您可以在您的项目中使用 Maven,那么我敢打赌它在那里会工作得更好! (我在 gwt-user 项目本身上遇到了问题,所以这对我来说不是一个选择)下次,我将尝试设置一个构建操作(或其他)来运行“javac -proc:only”而不是依赖 Eclipse 的内置(并且有很多错误)APT。

This post from Thomas Broyer the Google Web Toolkit Google Group solved the issue. Here's a quote:

Annotation processing in Eclipse a barely usable. I battled for hours yesterday to make it refresh the generated DeobfuscatorBuilder. IIRC, I refresh the project in eclipse, then restarted it, then disabled annotation processing, deleted the .apt_generated folder and re-enabled annotation processing. If you can use Maven for your project, then I'd bet it works much better there! (I had the issue on the gwt-user project itself, so it wasn't an option for me) Next time, I'll try setting up a build action (or whatever) to run "javac -proc:only" instead of relying of Eclipse's built-in (and awfully buggy) APT.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文