【发布时间】:2023-03-25 01:03:01
【问题描述】:
你们能帮我解释一下为什么会出现这个异常吗?
我将 RequestFactory 代理和上下文接口提取到单独的 jar 中,这样我就可以在 GWT 客户端和 Android 客户端中使用它(详细信息是 here)
不幸的是,RF 在第一次调用时就在服务器上引发了异常。例外是:
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 注入的自定义定位器编译为将在移动设备上运行的 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");
}
}
它没有为工厂生成令牌。因此,没有对 Deobfuscator.Builder.withOperation 的调用,因此当调用来自客户端时,我的服务器无法找到上下文。
问题是:
- 为什么 RequestFactory 注释工具不为工厂(操作)生成令牌?
- 我该如何解决?
【问题讨论】:
标签: android gwt annotations gwt2 requestfactory