Getting NullPointerException in GWT app but not sure how -
getting uncaught exception escaped java.lang.nullpointerexception: null
i getting error when calling
private final observerregistrationimpl<events.wordlistevent> wordlistadditionobservers = new observerregistrationimpl<events.wordlistevent>(); public void addwordlists(arraylist<wordlist> wordlists) { for(wordlist wl : wordlists) { gwt.log( "model: adding wordlist: "+wl.getname()); this.wordlists.add(wl); //error happens on line below this.wordlistadditionobservers.notifyobservers(this, new events.wordlistevent(wl)); } }
i checked in debug mode , saw wordlistadditionobservers
, w1
, this
objects. none null. wrong?
here observerregistrationimpl class
public class observerregistrationimpl<t> implements observable<t> { private list<observer<t>> observers = new arraylist<observer<t>>(); @override public void addobserver(observer<t> o) { this.observers.add(o); } @override public void removeallobservers() { this.observers.clear(); } @override public void removeobserver(observer<t> o) { this.observers.remove(o); } @override public void notifyobservers(modelviewinterface model, t event) { for(observer<t> o : this.observers) o.notify(model, event); } }
here stacktrace
uncaught exception escaped <pre>java.lang.nullpointerexception: null @ com.example.gwt.myapplication.listeditor.client.observerregistrationimpl.notifyobservers(observerregistrationimpl.java:29) @ com.example.gwt.myapplication.listeditor.client.model.addwordlists(model.java:103) @ com.example.gwt.myapplication.listeditor.client.controllerauthentication$2.onxmlparsed(controllerauthentication.java:74) @ com.example.gwt.myapplication.listeditor.client.controllerauthentication$2.onxmlparsed(controllerauthentication.java:1) @ com.example.gwt.myapplication.listeditor.client.remoterequest.doparsexml(remoterequest.java:291) @ com.example.gwt.myapplication.listeditor.client.remoterequest.access$0(remoterequest.java:282) @ com.example.gwt.myapplication.listeditor.client.remoterequest$1.onresponsereceived(remoterequest.java:209) @ com.google.gwt.http.client.request.fireonresponsereceived(request.java:287) @ com.google.gwt.http.client.requestbuilder$1.onreadystatechange(requestbuilder.java:393) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ com.google.gwt.dev.shell.methodadaptor.invoke(methodadaptor.java:103) @ com.google.gwt.dev.shell.methoddispatch.invoke(methoddispatch.java:71) @ com.google.gwt.dev.shell.oophmsessionhandler.invoke(oophmsessionhandler.java:157) @ com.google.gwt.dev.shell.browserchannel.reacttomessageswhilewaitingforreturn(browserchannel.java:1714) @ com.google.gwt.dev.shell.browserchannelserver.invokejavascript(browserchannelserver.java:165) @ com.google.gwt.dev.shell.modulespaceoophm.doinvoke(modulespaceoophm.java:120) @ com.google.gwt.dev.shell.modulespace.invokenative(modulespace.java:507) @ com.google.gwt.dev.shell.modulespace.invokenativeobject(modulespace.java:264) @ com.google.gwt.dev.shell.javascripthost.invokenativeobject(javascripthost.java:91) @ com.google.gwt.core.client.impl.impl.apply(impl.java) @ com.google.gwt.core.client.impl.impl.entry0(impl.java:188) @ sun.reflect.generatedmethodaccessor14.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ com.google.gwt.dev.shell.methodadaptor.invoke(methodadaptor.java:103) @ com.google.gwt.dev.shell.methoddispatch.invoke(methoddispatch.java:71) @ com.google.gwt.dev.shell.oophmsessionhandler.invoke(oophmsessionhandler.java:157) @ com.google.gwt.dev.shell.browserchannel.reacttomessages(browserchannel.java:1669) @ com.google.gwt.dev.shell.browserchannelserver.processconnection(browserchannelserver.java:401) @ com.google.gwt.dev.shell.browserchannelserver.run(browserchannelserver.java:222) @ java.lang.thread.run(unknown source)</pre>
i followed problem in debugger , noticed thowing exception @ following gwt code
} catch (invocationtargetexception e) { // if here, means exception being thrown // java javascript wrapexception(returnvalue, e.gettargetexception()); return true;
(answered in comments. converted community wiki answer. see question no answers, issue solved in comments (or extended in chat) )
the op wrote:
it turns out view getting passed controller null because doing
private controllerwordlists controller = new controllerwordlists(this);
in instance variable. why possible? why there no compile error? weird.
Comments
Post a Comment