Skip to content

GWT-ext common problems – the null pointer

I’ve been working a lot lately with the Google Web Toolkit Extensions rich user interface platform (GWT-ext).

While I don’t have the time to cover many of the issues relating to general usage of the API, from time to time I hope to post some useful information about it. Using GWT and the extension is a learning curve as it has some foibles and a unique deployment procedure to be aware of, but I’ve very much warmed to it as a tool in web user interface development.

So the issue at hand – a null pointer, which will not be picked up until run time and you will only see if you explicitly look at the javascript errors when browsing to your page. If you have unusual behaviour of a component or panel where it is not displaying, check your browsers javascript errors for complaints about null pointers.

The cause – very often simply that you declared something and tried to use it without first instantiating it.


Panel otherpanel;
Panel panel;
panel.setTitle(“Hello mate”);
otherpanel = new Panel();   <– you instantiated this one here, but not the other one

Here ‘panel’ has not been instantiated before it is used, a simple but easy to miss error especially and it is not always picked up by the IDE and java compiler.

So check if you’re trying to use something without being instantiated first, before you start tearing your hair out about why its not working!

Leave a Reply