0

如果我启动 URL [code]http://localhost:8888/app1.html?[/code] 并单击一个按钮,它工作正常。在本地主机上调用我的 RPC 很好。但是,如果我随后更改 URL 以使客户端处于调试模式,即 [code]http://localhost:8888/app1.html?gwt.codesvr=localhost:[/code] 然后它会在它的位置引发异常调用本地服务器上的 RPC 服务。

这是异常代码。

08:08:41.482 [ERROR] [nquizitive] Uncaught exception escaped

com.google.gwt.event.shared.UmbrellaException: One or more exceptions caught, see full set in UmbrellaException#getCauses
    at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129)
    at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:129)
    at com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116)
    at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:177)
    at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1351)
    at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1307)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
    at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
    at sun.reflect.GeneratedMethodAccessor31.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.AssertionError: null
    at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.<init>(RequestCallbackAdapter.java:182)
    at com.google.gwt.user.client.rpc.impl.RemoteServiceProxy.doCreateRequestCallback(RemoteServiceProxy.java:347)
    at com.google.gwt.user.client.rpc.impl.RemoteServiceProxy.doPrepareRequestBuilderImpl(RemoteServiceProxy.java:433)
    at com.google.gwt.user.client.rpc.impl.RemoteServiceProxy.doInvoke(RemoteServiceProxy.java:368)
    at com.google.gwt.user.client.rpc.impl.RemoteServiceProxy$ServiceHelper.finish(RemoteServiceProxy.java:74)
    at com.app.nquizitive.client.service.CategoryService_Proxy.createCategory(CategoryService_Proxy.java:32)
    at com.app.nquizitive.client.presenter.HomeViewPresenter$2.onClick(HomeViewPresenter.java:60)
    at com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:54)
    at com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:1)
    at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
    at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)
    at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
    at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
    at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)
    at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:129)
    at com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116)
    at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:177)
    at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1351)
    at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1307)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
    at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
    at sun.reflect.GeneratedMethodAccessor31.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
    at java.lang.Thread.run(Unknown Source)

导致问题的行是对类别服务的调用。

public void onClick(ClickEvent event){
    display.getNewCategoryName();
    categoryService.createCategory( display.getNewCategoryName(), null )
}

刚刚注意到我得到了异常,因为异步回调为空。如果我对响应不感兴趣,我可以不将其设置为 null。这基本上是一个火灾和忘记电话。

这是有效的代码

public void onClick(ClickEvent event){

     display.getNewCategoryName();
     categoryService.createCategory( display.getNewCategoryName(), new AsyncCallback(){

         public void onFailure(Throwable caught){
             Window.alert("Error fetching categorys");
         }

         @Override
         public void onSuccess(Object result){
             //New Category added so update display
             fetchCategorys();
         }

     });
}

仍然不明白为什么 null Async 回调对象在运行模式下工作:(

4

2 回答 2

2

在 prod 模式下它不会失败的原因是这是一个断言 ( assert callback != null),并且断言在 prod 模式下默认禁用。

鉴于没有代码在调用之前onSuccessonFailure在它上检查回调是否为空(因为,你知道,我们已经断言它是非空的),我敢打赌它实际上在 prod 模式下确实失败了:如果你看JS 控制台在您的浏览器中,您应该会看到一个错误,例如cannot call method 'xxx' of null。如果你有一个GWT.UncaughtExceptionHandler它会被回调那个错误。

于 2013-02-06T10:08:16.043 回答
0

如果您在调试配置参数选项卡中看到

-remoteUI "${gwt_remote_ui_server_port}:${unique_id}" -startupUrl index.html -logLevel INFO -codeServerPort 9997 -port 8888 -war E:\workspace

远程Ui服务器端口应该有一个codeServerPort 端口9997 ..所以你必须提供你的网址,如下所示

http://127.0.0.1:8888/app1.html?gwt.codesvr=127.0.0.1:9997

您可以在 eclipse debug config 中更改端口。

于 2013-02-06T09:06:06.040 回答