2012-04-17 28 views
1

请问你们能帮我解释为什么我有这个例外吗?

我提取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) 

下面是我的工厂界面。正如你所看到的,我必须用ServiceName替换Service注释,因为我不想用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注释工具给了如下警告:

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场正​​在被初始化由DeobfuscatorBuilder由RequestFactory注释工具生成的类。

所以...我反编译该类和发现这一点:工厂

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注释工具生成工厂(操作)令牌?
  • 我该如何解决?

回答

1

嗯,这是相当棘手......但是在RF注释工具调试帮助:)

原来你必须有你在RF注解处理器的类路径是指在@ServiceName域类。它造成鸡与鸡蛋的问题。您必须编译SharedClasses模块才能编译主模块,但必须从主模块编译域类以编译SharedClasses模块。

这里是我所做的:为SharedClasses模块

  • 残疾人RF注释处理。
  • 在主模块我明确指定的RF工厂,必须使用参数rootOverride = com.blah.shared.factories.AdminRequestFactory

它吮吸,我在项目设置虽然硬编码的全限定类名被处理的RF注释处理器

如果你们知道更优雅的方法,请让我知道。

0

我也遇到同样的问题。基本上我有3个GWT模块1.主模块和第二个模块中我有requestFactory,服务器域类和客户端代理值。我非常肯定你的解决方案就是我需要的。不过,我很困惑如何在Maven构建阶段指定rootOverride。 pom.xml结构中的任何指针都会非常有用。

+0

我建议删除这篇文章,因为它显然不是一个答案(尽管你可以发布它作为答案)。 – fdreger 2014-08-29 11:50:22

相关问题