2012-01-23 61 views
0

我想在Eclipse上自定義App Engine Connected Android項目。我使用Objectify代替JPA,並且一直遵循Turbocharge示例來設置我的基本框架(使用DAO層)。我正在從事網絡方面的工作,但我無法讓我的實體堅持在開發服務器上:我的請求在Receivers的onFailure()方法上返回ServerFailure錯誤。但並沒有提供任何線索,爲什麼這是(所有變量都爲空)。GWT RequestFactory與Objectify:ServerFailure錯誤時返回請求時觸發

任何幫助將不勝感激!

這裏是我的入口點類:

public class Manager implements EntryPoint { 
private static final Logger log = Logger.getLogger(Manager.class.getName()); 
private final EventBus eventBus = new SimpleEventBus(); 
private ManagerRequestFactory rf = GWT.create(ManagerRequestFactory.class); 

@Override 
public void onModuleLoad() { 
    GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() { 

     @Override 
     public void onUncaughtException(Throwable e) { 
      log.finest("uncaught exception: "); 
      e.printStackTrace(); 
     } 
    }); 

    rf.initialize(eventBus); 
    log.setLevel(Level.FINE); 
    PersonRequest personRequest = rf.personRequest(); 

    // Populate the database with sample data 
    PersonProxy person = personRequest.create(PersonProxy.class); 

    person.setFirstName("John1"); 
    person.setLastName("Doe"); 
    person.setEmail("[email protected]"); 
    person.setMainPhone("215-555-1212"); 
    personRequest.saveAndReturn(person).fire(new Receiver<PersonProxy>(){ 

     @Override 
     public void onSuccess(PersonProxy response) { 
      log.info("got response: " + response.getFirstName()); 

     } 

     @Override 
     public void onFailure(ServerFailure error) { 
      log.info("Server Failure type: " + error.getExceptionType()); 
      log.info("Failure message: " + error.getMessage()); 
      log.info("Stack Trace: " + error.getStackTraceString()); 
      log.info(error.isFatal() ? "error is fatal" : "error is not fatal"); 
      super.onFailure(error); 
     } 
    }); 

我也跟着在調試模式下的代碼通過堆到返回錯誤的點。這裏的堆棧

Daemon Thread [Code server for manager from Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7 on http://127.0.0.1:8888/manager/hosted.html?manager @ d6:JVCMo.q:W,$wW] (Suspended (exception UmbrellaException))

AbstractRequestContext$StandardPayloadDialect.processPayload(Receiver<Void>, String) line: 387 
AbstractRequestContext$5.onTransportSuccess(String) line: 1108 
DefaultRequestTransport$1.onResponseReceived(Request, Response) line: 136 
Request.fireOnResponseReceived(RequestCallback) line: 287 
RequestBuilder$1.onReadyStateChange(XMLHttpRequest) line: 395 
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] 
NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available 
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available 
Method.invoke(Object, Object...) line: not available  
MethodAdaptor.invoke(Object, Object...) line: 103 
MethodDispatch.invoke(JsValue, JsValue[], JsValue) line: 71 
OophmSessionHandler.invoke(BrowserChannelServer, BrowserChannel$Value, int, BrowserChannel$Value[]) line: 172 
BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer$SessionHandlerServer) line: 337 
BrowserChannelServer.invokeJavascript(CompilingClassLoader, JsValueOOPHM, String, JsValueOOPHM[], JsValueOOPHM) line: 218 
ModuleSpaceOOPHM.doInvoke(String, Object, Class<?>[], Object[]) line: 136 
ModuleSpaceOOPHM(ModuleSpace).invokeNative(String, Object, Class<?>[], Object[]) line: 561 
ModuleSpaceOOPHM(ModuleSpace).invokeNativeObject(String, Object, Class<?>[], Object[]) line: 269  
JavaScriptHost.invokeNativeObject(String, Object, Class<?>[], Object[]) line: 91  
Impl.apply(Object, Object, Object) line: not available 
Impl.entry0(Object, Object, Object) line: 213 
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] 
NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available 
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available 
Method.invoke(Object, Object...) line: not available  
MethodAdaptor.invoke(Object, Object...) line: 103 
MethodDispatch.invoke(JsValue, JsValue[], JsValue) line: 71 
OophmSessionHandler.invoke(BrowserChannelServer, BrowserChannel$Value, int, BrowserChannel$Value[]) line: 172 
BrowserChannelServer.reactToMessages(BrowserChannelServer$SessionHandlerServer) line: 292 
BrowserChannelServer.processConnection() line: 546 
BrowserChannelServer.run() line: 363  
Thread.run() line: not available  

在這裏,我有變量的快照響應和錯誤:

response ResponseMessageAutoBean$1 (id=566) 
    this$0 ResponseMessageAutoBean (id=581) 
     data JsonSplittable (id=583)  
      array null  
      bool null  
      isNull false 
      number null  
      obj JSONObject (id=597)  
      reified HashMap<K,V> (id=598) 
      string null  
     factory MessageFactoryImpl (id=584)  
      creatorMap JavaScriptObject$ (id=608) 
      enumToStringMap HashMap<K,V> (id=609) 
      stringsToEnumsMap HashMap<K,V> (id=610) 
     frozen false 
     shim ResponseMessageAutoBean$1 (id=566) 
      this$0 ResponseMessageAutoBean (id=581) 
       data JsonSplittable (id=583)  
       factory MessageFactoryImpl (id=584)  
       frozen false 
       shim ResponseMessageAutoBean$1 (id=566) 
       tags null  
       usingSimplePeer true  
       wrapped ResponseMessageAutoBean$2 (id=587) 
     tags null  
     usingSimplePeer true  
     wrapped ResponseMessageAutoBean$2 (id=587) 

causes HashSet<E> (id=570)  
    [0] RuntimeException (id=576) 
     cause RuntimeException (id=576) 
     detailMessage "Server Error: null" (id=579) 
     stackTrace null  
+0

具有相同的問題,並且一直無法找到解決方案。 – Patrick

+0

您是否找到解決方案? – amrfaissal

+0

我做過了,對於剛纔的確切解決方案我有點含糊不清......問題不在我的代碼中。我記得不得不刪除一個或多個gwt自動生成或編譯的代碼,並讓GWT再次編譯它。希望這有助於指向正確的方向! –

回答

0

此錯誤表明服務器有一個錯誤,因此「服務器錯誤:空「 - 拋出異常,但沒有任何消息與它發送給客戶端相關聯。根據您的代碼,它可能位於服務器上的saveAndReturn方法中。嘗試通過那裏,或用try/catch圍繞方法的主體來獲取錯誤。如果發生錯誤時正在使用足夠的日誌記錄,則您的服務器日誌可能會更清楚地說明問題。

+0

服務器上的代碼很少,只有3行調用ofy()。put()並試圖捕獲id返回值。還有其他事情正在發生。我只是用Objectify的DaoBase類包裝ofy()。put()調用簡化了代碼。現在,當我嘗試驗證RequestFactoryDe​​obfuscatorBuilder.java文件時,它在我的開發控制檯中出現錯誤。顯然它是在沒有任何對某些類的引用的情況下構建的: –

+0

請確保您正在運行RequestFactory的註釋處理部分 - 這在2.4.0中是新的。如果使用eclipse進行構建,請查看http://code.google.com/p/google-web-toolkit/wiki/RequestFactoryInterfaceValidation,如果使用maven,則可以跳過所有這些廢話,只需在添加com後進行全新安裝即可。 google.web.bindery:requestfactory-apt:2.4.0'給你的pom。 –

+0

感謝科林,我確實早就過來了,但並不認爲這是問題所在。我使用eclipse,並在註釋處理/工廠路徑首選項中檢查了com.google.gwt.eclipse.sdkbundle_2.4.0.v201112160242-rel-r37 \ gwt-2.4.0 \ requestfactory_apt.jar下的文件。維基的第二部分我不明白,如果我使用'@ServiceName'註釋,我認爲我需要使用'驗證工具',但解釋並不能幫助我理解如何實現它。同時我會嘗試使用'@Service'。 –

相關問題