Search code examples
google-app-enginegwtrequestfactoryobjectify

GWT RequestFactory with Objectify: ServerFailure error returns when firing request


I'm trying to customize the App Engine Connected Android project on Eclipse. I'm using Objectify in place of JPA and have been following the Turbocharge example to setup my basic framework (using a DAO layer).

I'm currently working on the web side of things, but I'm having trouble getting my entities to persist on the development server: my requests return a ServerFailure error on Receivers' onFailure() method. But doesn't really provide any clues as to why that is (all variables are null).

Any help would be greatly appreciated!

Here's my EntryPoint class:

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("jd@gmail.com");
    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);
        }
    });

I followed the code in debug mode through the stacks to the point where it returns the error. Here's the Stack

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    

And here I have a snapshot of the Variables for response and error:

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    

Solution

  • This error indicates that the server had an error, hence "Server Error: null" - an exception was thrown, but no message was associated with it to send to the client. Based on your code, it is probably in the saveAndReturn method on the server. Try stepping through there, or surrounding the body of the method with a try/catch to get the error. Your server log may shed more light on the issue, if enough logging is being used when errors occur.