GWT RequestFactory:获取“没有令牌类型...”例外
我是 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能缺少所需的
with()
。尝试类似
req.save(person).with("address").fire();
You're probably missing the needed
with()
.Try something like
req.save(person).with("address").fire();
这篇文章来自 Google 网络工具包谷歌集团解决了这个问题。这是一个引用:
This post from Thomas Broyer the Google Web Toolkit Google Group solved the issue. Here's a quote: