2

我有简单的 GWT 2.4.0 RequestFactory 应用程序,当调用 fire 方法时,它会因客户端异常而失败。

context.checkPassword(tbLogin.getText(), ptbPasswd.getText())
        .fire(new Receiver<EmployeeProxy>() {

            @Override
            public void onSuccess(EmployeeProxy response) {
                Window.alert(response == null ?
                        "Login faild!" :
                        response.getDisplayName()
                                + " login success!");
            }

            @Override
            public void onFailure(ServerFailure error) {
                Window.alert("Somthing wrong");
            }

        });

FireBug 和 Chrome 开发者工具什么也没显示。我刚刚收到一条警报消息:

(TypeError): b is null
 fileName: http://localhost:8084/app/BDB5AC36BC159624D4B51B3846C167DF.cache.html
 stack: Oz(null,"{\"F\":\"ru.itskills.daxx.acme.client.EmployeeRequestFactory\",\"I\":[{\"O\":\"yGR3sMWWOGTu_ikQGxTCqleAi3E=\",\"P\":[\"cas\",\"cas1\"]}]}",[object Object])@http://localhost:8084/app/BDB5AC36BC159624D4B51B3846C167DF.cache.html:1197
gB([object Object],null)@http://localhost:8084/app/BDB5AC36BC159624D4B51B3846C167DF.cache.html:1169
jB([object Object])@http://localhost:8084/app/BDB5AC36BC159624D4B51B3846C167DF.cache.html:1079
VA([object Object],[object Object])@http://localhost:8084/app/BDB5AC36BC159624D4B51B3846C167DF.cache.html:475
YW([object Object])@http://localhost:8084/app/BDB5AC36BC159624D4B51B3846C167DF.cache.html:1172
Pc([object Object])@http://localhost:8084/app/BDB5AC36BC159624D4B51B3846C167DF.cache.html:1253
Bc([object Object])@http://localhost:8084/app/BDB5AC36BC159624D4B51B3846C167DF.cache.html:1253
Ad([object Object],[object Object],null)@http://localhost:8084/app/BDB5AC36BC159624D4B51B3846C167DF.cache.html:1216
sd([object Object],[object Object])@http://localhost:8084/app/BDB5AC36BC159624D4B51B3846C167DF.cache.html:1170
Ho([object Object],[object Object])@http://localhost:8084/app/BDB5AC36BC159624D4B51B3846C167DF.cache.html:532
Hc([object MouseEvent],[object Object],[object HTMLButtonElement])@http://localhost:8084/app/BDB5AC36BC159624D4B51B3846C167DF.cache.html:1077
Jo([object Object],[object MouseEvent])@http://localhost:8084/app/BDB5AC36BC159624D4B51B3846C167DF.cache.html:1014
Ro([object MouseEvent])@http://localhost:8084/app/BDB5AC36BC159624D4B51B3846C167DF.cache.html:1253
vn([object MouseEvent],[object HTMLButtonElement],[object Object])@http://localhost:8084/app/BDB5AC36BC159624D4B51B3846C167DF.cache.html:935
([object MouseEvent])@http://localhost:8084/app/BDB5AC36BC159624D4B51B3846C167DF.cache.html:1250
zb((function (a) {var b, c = this;while (c && !(b = c.__listener)) {c = c.parentNode;}c && c.nodeType != 1 && (c = null);b && $n(b) && vn(a, c, b);}),[object HTMLButtonElement],[object Arguments])@http://localhost:8084/app/BDB5AC36BC159624D4B51B3846C167DF.cache.html:663
Cb((function (a) {var b, c = this;while (c && !(b = c.__listener)) {c = c.parentNode;}c && c.nodeType != 1 && (c = null);b && $n(b) && vn(a, c, b);}),[object HTMLButtonElement],[object Arguments])@http://localhost:8084/app/BDB5AC36BC159624D4B51B3846C167DF.cache.html:1164
([object MouseEvent])@http://localhost:8084/app/BDB5AC36BC159624D4B51B3846C167DF.cache.html:965

 lineNumber: 1197

它可能是什么以及如何解决它?

“详细”模式编译后出现同样的错误。

(TypeError): this$static is null
 fileName: http://localhost:8888/app/247A5A4B14F8C1DBCC38D63FB852104D.cache.html
 stack: com_google_web_bindery_requestfactory_gwt_client_DefaultRequestTransport_$send__Lcom_google_web_bindery_requestfactory_gwt_client_DefaultRequestTransport_2Ljava_lang_String_2Lcom_google_web_bindery_requestfactory_shared_RequestTransport$TransportReceiver_2V(null,"{\"F\":\"ru.itskills.daxx.acme.client.EmployeeRequestFactory\",\"I\":[{\"O\":\"yGR3sMWWOGTu_ikQGxTCqleAi3E=\",\"P\":[\"cas\",\"cas1\"]}]}",[object Object])@http://localhost:8888/app/247A5A4B14F8C1DBCC38D63FB852104D.cache.html:6394
com_google_web_bindery_requestfactory_shared_impl_AbstractRequestContext_$doFire__Lcom_google_web_bindery_requestfactory_shared_impl_AbstractRequestContext_2Lcom_google_web_bindery_requestfactory_shared_Receiver_2V([object Object],null)@http://localhost:8888/app/247A5A4B14F8C1DBCC38D63FB852104D.cache.html:6925
com_google_web_bindery_requestfactory_shared_impl_AbstractRequestContext_$fire__Lcom_google_web_bindery_requestfactory_shared_impl_AbstractRequestContext_2V([object Object])@http://localhost:8888/app/247A5A4B14F8C1DBCC38D63FB852104D.cache.html:6993
com_google_web_bindery_requestfactory_shared_impl_AbstractRequest_$fire__Lcom_google_web_bindery_requestfactory_shared_impl_AbstractRequest_2Lcom_google_web_bindery_requestfactory_shared_Receiver_2V([object Object],[object Object])@http://localhost:8888/app/247A5A4B14F8C1DBCC38D63FB852104D.cache.html:6825
ru_itskills_daxx_acme_client_App$1_$onClick__Lru_itskills_daxx_acme_client_App$1_2Lcom_google_gwt_event_dom_client_ClickEvent_2V([object Object])@http://localhost:8888/app/247A5A4B14F8C1DBCC38D63FB852104D.cache.html:14243
com_google_gwt_event_dom_client_ClickEvent_dispatch__Lcom_google_gwt_event_shared_EventHandler_2V([object Object])@http://localhost:8888/app/247A5A4B14F8C1DBCC38D63FB852104D.cache.html:713
com_google_gwt_event_shared_GwtEvent_dispatch__Ljava_lang_Object_2V([object Object])@http://localhost:8888/app/247A5A4B14F8C1DBCC38D63FB852104D.cache.html:633
com_google_web_bindery_event_shared_SimpleEventBus_$doFire__Lcom_google_web_bindery_event_shared_SimpleEventBus_2Lcom_google_web_bindery_event_shared_Event_2Ljava_lang_Object_2V([object Object],[object Object],null)@http://localhost:8888/app/247A5A4B14F8C1DBCC38D63FB852104D.cache.html:916
com_google_gwt_event_shared_HandlerManager_$fireEvent__Lcom_google_gwt_event_shared_HandlerManager_2Lcom_google_gwt_event_shared_GwtEvent_2V([object Object],[object Object])@http://localhost:8888/app/247A5A4B14F8C1DBCC38D63FB852104D.cache.html:848
com_google_gwt_user_client_ui_Widget_$fireEvent__Lcom_google_gwt_user_client_ui_Widget_2Lcom_google_gwt_event_shared_GwtEvent_2V([object Object],[object Object])@http://localhost:8888/app/247A5A4B14F8C1DBCC38D63FB852104D.cache.html:2898
com_google_gwt_event_dom_client_DomEvent_fireNativeEvent__Lcom_google_gwt_dom_client_NativeEvent_2Lcom_google_gwt_event_shared_HasHandlers_2Lcom_google_gwt_dom_client_Element_2V([object MouseEvent],[object Object],[object HTMLButtonElement])@http://localhost:8888/app/247A5A4B14F8C1DBCC38D63FB852104D.cache.html:662
com_google_gwt_user_client_ui_Widget_$onBrowserEvent__Lcom_google_gwt_user_client_ui_Widget_2Lcom_google_gwt_user_client_Event_2V([object Object],[object MouseEvent])@http://localhost:8888/app/247A5A4B14F8C1DBCC38D63FB852104D.cache.html:2926
com_google_gwt_user_client_ui_Widget_onBrowserEvent__Lcom_google_gwt_user_client_Event_2V([object MouseEvent])@http://localhost:8888/app/247A5A4B14F8C1DBCC38D63FB852104D.cache.html:2993
com_google_gwt_user_client_DOM_dispatchEvent__Lcom_google_gwt_user_client_Event_2Lcom_google_gwt_user_client_Element_2Lcom_google_gwt_user_client_EventListener_2V([object MouseEvent],[object HTMLButtonElement],[object Object])@http://localhost:8888/app/247A5A4B14F8C1DBCC38D63FB852104D.cache.html:2348
([object MouseEvent])@http://localhost:8888/app/247A5A4B14F8C1DBCC38D63FB852104D.cache.html:2617
com_google_gwt_core_client_impl_Impl_apply__Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2((function (evt) {var listener, curElem = this;while (curElem && !(listener = curElem.__listener)) {curElem = curElem.parentNode;}curElem && curElem.nodeType != 1 && (curElem = null);listener && com_google_gwt_user_client_impl_DOMImpl_isMyListener__Ljava_lang_Object_2Z(listener) && com_google_gwt_user_client_DOM_dispatchEvent__Lcom_google_gwt_user_client_Event_2Lcom_google_gwt_user_client_Element_2Lcom_google_gwt_user_client_EventListener_2V(evt, curElem, listener);}),[object HTMLButtonElement],[object Arguments])@http://localhost:8888/app/247A5A4B14F8C1DBCC38D63FB852104D.cache.html:269
com_google_gwt_core_client_impl_Impl_entry0__Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2((function (evt) {var listener, curElem = this;while (curElem && !(listener = curElem.__listener)) {curElem = curElem.parentNode;}curElem && curElem.nodeType != 1 && (curElem = null);listener && com_google_gwt_user_client_impl_DOMImpl_isMyListener__Ljava_lang_Object_2Z(listener) && com_google_gwt_user_client_DOM_dispatchEvent__Lcom_google_gwt_user_client_Event_2Lcom_google_gwt_user_client_Element_2Lcom_google_gwt_user_client_EventListener_2V(evt, curElem, listener);}),[object HTMLButtonElement],[object Arguments])@http://localhost:8888/app/247A5A4B14F8C1DBCC38D63FB852104D.cache.html:301
([object MouseEvent])@http://localhost:8888/app/247A5A4B14F8C1DBCC38D63FB852104D.cache.html:286

 lineNumber: 6394
4

2 回答 2

2

从您的代码片段中,可以null检查和不检查三件事:

  1. tbLogin.getText()
  2. ptbPasswd.getText()
  3. response.getDisplayName()

要追查问题,请使用“输出样式:详细”编译项目并重新测试。该错误将显示 Java 堆栈而不是“b 为空”。

在此处输入图像描述

如果您通过 ANT 编译,请添加-style DETAILEDarg,例如:

<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
    ...
    <arg line="-style" />
    <arg value="DETAILED" />
    ...
</java>
于 2012-06-05T06:46:08.753 回答
0

我敢打赌你忘了initialize()你的 RequestFactory。

于 2012-06-05T11:30:46.287 回答