- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
你们能帮我看看为什么会出现这个异常吗?
我将 RequestFactory 代理和上下文接口(interface)提取到单独的 jar 中,这样我就可以在 GWT 客户端和 Android 客户端中使用它(详细信息是 here )
不幸的是,RF 在第一次调用时在服务器上抛出异常。异常(exception)情况是:
com.google.web.bindery.requestfactory.server.UnexpectedException: No RequestContext for operation LPZEK7DlYkoG1$NQ5MjHlmuRChk=
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.die(ServiceLayerDecorator.java:216)
at com.google.web.bindery.requestfactory.server.ResolverServiceLayer.resolveRequestContext(ResolverServiceLayer.java:154)
下面是我的工厂界面。如您所见,我不得不将 Service
注释替换为 ServiceName
,因为我不想将所有带有 Guice 注入(inject)的自定义定位器编译到将在移动设备上运行的 jar。
public interface AdminRequestFactory extends RequestFactory
{
// @Service(value = UserServiceDao.class, locator = InjectingServiceLocator.class)
@ServiceName(value = "com.blah.courierApp.server.dao.UserServiceDao", locator = "com.blah.courierApp.server.inject.InjectingServiceLocator")
public interface GaeUserServiceContext extends RequestContext
{
public Request<String> createLogoutURL(String destinationURL);
public Request<GaeUser> getCurrentUser();
}
// @Service(value = OrderDao.class, locator = InjectingServiceLocator.class)
@ServiceName(value = "com.blah.courierApp.server.dao.OrderDao", locator = "com.blah.courierApp.server.inject.InjectingServiceLocator")
public interface OrderRequestContext extends RequestContext
{
Request<List<OrderProxy>> listAll();
Request<Void> delete(Long id);
Request<Void> createOrder(OrderProxy order);
Request<OrderProxy> findOrderById(long id);
Request<Void> updateOrderState(long id, StateType newStateType);
}
GaeUserServiceContext contextUserService();
OrderRequestContext contextOrder();
}
当我编译它时,RF Annotation Tool 给出了以下警告:
Cannot fully validate context since domain type com.blah.courierApp.server.dao.UserServiceDao is not available.
You must run the ValidationTool as part of your server build process.
Add @SuppressWarnings("requestfactory") to dismiss.
因此,当服务器上的调试器抛出异常时,我看到 com.google.web.bindery.requestfactory.vm.impl.Deobfuscator
的实例有空 operationData
由 RequestFactory 注释工具生成的 DeobfuscatorBuilder
类初始化的字段。
所以...我反编译了那个类并发现了这个:
public final class AdminRequestFactoryDeobfuscatorBuilder extends Deobfuscator.Builder
{
public AdminRequestFactoryDeobfuscatorBuilder()
{
withRawTypeToken("w1Qg$YHpDaNcHrR5HZ$23y518nA=", "com.google.web.bindery.requestfactory.shared.EntityProxy");
withRawTypeToken("8KVVbwaaAtl6KgQNlOTsLCp9TIU=", "com.google.web.bindery.requestfactory.shared.ValueProxy");
withRawTypeToken("FXHD5YU0TiUl3uBaepdkYaowx9k=", "com.google.web.bindery.requestfactory.shared.BaseProxy");
withRawTypeToken("5vjE9LUy$l0uvi4kMYpS3JA1WEE=", "com.blah.shared.model.GaeUser");
withRawTypeToken("8KVVbwaaAtl6KgQNlOTsLCp9TIU=", "com.google.web.bindery.requestfactory.shared.ValueProxy");
withRawTypeToken("5a7OV4PSV$1xemsooKLfEQ4g5yY=", "com.blah.shared.proxies.OrderProxy");
withRawTypeToken("neR_xIhE5oZsc0HbnkAMa8A88yw=", "com.blah.shared.proxies.OrderStateProxy");
withRawTypeToken("t6gMQWDROJnYvqYhNURV8pd$sn4=", "com.blah.shared.proxies.OrganizationProxy");
withRawTypeToken("1o45xgS$5bIkBKF4wlR8oMw_FSo=", "com.blah.shared.proxies.PersonProxy");
withRawTypeToken("FXHD5YU0TiUl3uBaepdkYaowx9k=", "com.google.web.bindery.requestfactory.shared.BaseProxy");
}
}
它没有为工厂生成 token 。因此,没有对 Deobfuscator.Builder.withOperation
的调用,因为当调用来自客户端时,我的服务器无法找到上下文。
问题是:
最佳答案
好吧,这很棘手...但是在 RF Annotation Tool 中进行调试很有帮助:)
事实证明,您必须在 RF 注释处理器的类路径中的 @ServiceName
中引用域类。它会产生先有鸡还是先有蛋的问题。您必须编译 SharedClasses
模块来编译主模块,但您必须从主模块编译域类来编译 SharedClasses
模块。
这是我做的:
rootOverride = com.blah.shared.factories.AdminRequestFactory
处理的 RF 工厂虽然我在项目设置中硬编码了完全限定的类名,但很糟糕。
如果你们知道更优雅的方法请告诉我。
关于android - RequestFactory 失败,返回 "UnexpectedException: No RequestContext for operation LPZEK7DlYkoG1$NQ5MjHlmuRChk=",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10187003/
我是一名优秀的程序员,十分优秀!