开发者

GWT RPC fails outside EntryPoint class

The following works when it's in the EntryPoint class of my application, but not when it's moved somewhere else.

public MyServiceAsync service = GWT.create(MyService.class);

service.someFunction(callback);

It doesn't seem to throw an exception itself, but the application crashes on a NullPointerException when it looks for objects that were supposed to be instantiated with data from the se开发者_StackOverflowrvice call. I've tried to follow it through the debugger, but it never even makes it to the server-side code or the callback.

Am I missing something? I'd prefer that all my service calls not need to be dispatched from the EntryPoint class.


Has this issue been resolved? If not, can you provide a minimal code sample that reproduces the error you're getting?

Luke wrote:

a NullPointerException when it looks for objects that were supposed to be instantiated with data from the service call

This sounds like you may not be accounting for the asynchronous nature of the RPC call. Those objects won't be instantiated until the call returns. If you're trying to use them in code following the service call, that won't work. You need to use the callback's onSuccess() method to do anything that depends on having the results of the call available.

I'm really just guessing based on the information in your initial description. More details, including a sample if possible, would make it easier to provide a more definitive answer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜