2012-04-17 36 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

相關問題