I now understand what caused this callback failure. Nothing was wrong with my implementation of the whole RPC mechanism. The problem was very special and specific to the particular browser event in which I was calling it.
Let me explain, as this may benefit someone else. Doing an RPC during the Window.onWindowClosing() event will ALWAYS fail. IOW, invoking an asynchronous callback (xmlhttprequest) during the window.onbeforeunload event will result in the onFailure() method of your asynchronous callback instance to be called, even if it was successful in reaching the server. You are probably wondering how an asynchronous callback can actually callback to either success or failure since the callback occurs AFTER the onWindowClosing event, which by definition means the window has closed. In my case, the code being ran in my onWindowClosing event actually prevents the window from closing, because it is in fact "anti frame buster" code... preventing a "frame buster" website inside an iframe from "busting" or closing the window. So the window doesn't actually close in my situation, and I expected the callback to indeed callback, which it does... the problem is that it fails and doesn't succeed. Even scheduling the asynchronous request to happen 1ms after the onWindowClosing event doesn't help. Scheduling it much later, say a whole second later, does allow it to succeed. I don't need it to return with success, so I won't be scheduling it. I just can't rely on getting any data back from the server in this situation, which I can cope with. So my problem is solved and I no longer need any help. I hope my explanation of this very specific situation was adequate, but if anyone has any questions just let me know. On May 24, 12:53 pm, Sky <[email protected]> wrote: > Thanks for the response. > > Sorry, when I said the callback failed, I meant that the onFailure() > method gets called, not the onSuccess() method of the AsyncCallback > instance. The status code of the the StatusCodeException that is > thrown is 0, which is not a standard server error response. In other > words, it's not a server error. It must be something in the client > that thinks it can't connect to the server, even though the server > gets the request and runs it's appropriate method. > > There are no console errors. I don't know how to check the Jetty > console. > > Also, I intend to use google's AppEngine as my Java server, so testing > locally using the AppEngine instead of Jetty would be ideal, but it > appears to not be supported yet. > > On May 24, 8:28 am, kozura <[email protected]> wrote: > > > > > > > Not sure what you mean by status code 0, does your onFailure callback > > get called, and what is the exception sent to it? Also be sure to > > check both the Jetty console and the client-particular console for any > > errors that show up there. > > > On May 23, 9:49 pm, Sky <[email protected]> wrote: > > > > Hi all. > > > > I did the Stockwatcher RPC tutorial and it worked beautifully. I then > > > implemented my own very simple RPC callback for my own project and I > > > always get status code 0 returned... the callback always fails. Funny > > > thing is that the server method does indeed run, I debugged into it. > > > Only the client side seems to think the RPC callback fails. My > > > implementation is even more simple than the Stockwatcher RPC because I > > > am simply returning a Long, which is serializable. > > > > I discovered a thread mentioning that RPC doesn't quite work with App- > > > engine, so I created a new project without app-engine, copied all my > > > code and files over to that project and I still have the same result. > > > > I don't know what else to tell you to help me out here. I have studied > > > the RPC guide and am sure I've implemented it all correctly, including > > > the web.xml file. Not to mention the fact that the server code DOES > > > run. > > > > Thanks for any insight. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Google Web Toolkit" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]. > > For more options, visit this group > > athttp://groups.google.com/group/google-web-toolkit?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Google Web Toolkit" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group > athttp://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
