GWT客户端错误(TypeError):b为null

时间:2012-06-05 00:44:29

标签: java javascript gwt requestfactory

我有简单的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

2 个答案:

答案 0 :(得分:2)

在您的代码段中,有三件事可以null,但不会被检查:

  1. tbLogin.getText()
  2. ptbPasswd.getText()
  3. response.getDisplayName()
  4. 要追踪问题,请使用“输出样式:详细”编译项目并重新测试。该错误将显示Java堆栈而不是“b为null”。

    enter image description here

    如果您通过ANT进行编译,请添加-style DETAILED arg,例如:

    <java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
        ...
        <arg line="-style" />
        <arg value="DETAILED" />
        ...
    </java>
    

答案 1 :(得分:0)

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