2014-02-05 50 views
0

我有一個問題,獲取加載模塊時加載數據的初始RPC調用。在onModuleLoad GWT RPC調用實現失敗

我使用herehere的代碼適用。

的錯誤,如果失敗的是一個空指針,它的行爲就好像它甚至沒有進行RPC調用可言,因爲RPC的既不是內部調試消息出現在Eclipse中的測試控制檯。

MenuItems對象是一個ArrayList < ArrayList < String >>實現IsSerializable的對象,並具有按照this SO answer的SerializableWhiteList條目。該對象在RPC RemoteServiceServlet中生成。

控制檯還引用了AppController.java行

History.fireCurrentHistoryState(); 

(幾乎相同the GWT Contacts example

想法,爲什麼/在/這是怎麼誤入歧途?初始RPC調用的任何其他實現示例也會很好。

public class MVPtest implements EntryPoint { 

    MenuItems mItems; 

    public void onModuleLoad() { 
     MainServiceAsync rpcService = GWT.create(MainService.class); 

     System.out.println("Inside of mod load. rpcService = " + rpcService.toString()); 

     rpcService.getMenuItems(new AsyncCallback<MenuItems>() { 

      public void onFailure(Throwable caught) { 
       System.out.println("I failed..."); 
       caught.printStackTrace(); 
      } 

      public void onSuccess(MenuItems result) { 
       System.out.println("I got the menuitems."); 
       mItems = result; 
      } 

     }); 
     HandlerManager eventBus = new HandlerManager(null); 
     AppController appViewer = new AppController(rpcService, eventBus, mItems); 
     appViewer.go(RootLayoutPanel.get()); 
    } 
} 

的rpcService調試消息產生一個非空:

Inside of mod load. rpcService = com.******.******[email protected] 

回答

0

這種說法是很危險的:

AppController appViewer = new AppController(rpcService, eventBus, mItems); 

,因爲你的客戶端代碼將不witing的執行您的電話回覆。

像這樣的東西應該工作:

public class MVPtest implements EntryPoint { 

    MenuItems mItems; 

    public void onModuleLoad() { 
     MainServiceAsync rpcService = GWT.create(MainService.class); 

     System.out.println("Inside of mod load. rpcService = " + rpcService.toString()); 

     rpcService.getMenuItems(new AsyncCallback<MenuItems>() { 

      public void onFailure(Throwable caught) { 
       System.out.println("I failed..."); 
       caught.printStackTrace(); 
      } 

      public void onSuccess(MenuItems result) { 
       System.out.println("I got the menuitems."); 
       mItems = result; 
       HandlerManager eventBus = new HandlerManager(null); 
       AppController appViewer = new AppController(rpcService, eventBus, mItems); 
       appViewer.go(RootLayoutPanel.get()); 
      } 

     }); 
    } 
} 
+0

此實現產生了 了java.lang.RuntimeException:無法從字節緩存和 閱讀產生的原因:產生java.io.IOException:沒有足夠的空間磁盤。此外,「模塊負載的內部」。沒有出現。 – adv

+0

清理unitCache解決了上述問題,並修復了我的RPC調用,所以現在我開始調試下一個項目。 – adv