StockWatcher example. null pointer because root panel cannot find html element 'stockList'

615 views
Skip to first unread message

Anil

unread,
Aug 6, 2008, 9:33:23 PM8/6/08
to Google Web Toolkit
Apparently there is a null pointer because root panel cannot find html
element 'stockList'.

[ERROR] Unable to load module entry point class
com.google.gwt.sample.stockwatcher.client.StockWatcher (see associated
exception for details)
java.lang.NullPointerException: null
at
com.google.gwt.sample.stockwatcher.client.StockWatcher.onModuleLoad(StockWatcher.java:
67)

line 67 ----> RootPanel.get("stockList").add(mainPanel);


in the file StockWatcher.html:

<div id="stockList"></div>

I used the commands in the tutorial:

C:\Projects\gwt-windows-1.5.0\StockWatcher>projectCreator -eclipse
StockWatcher -out StockWatcher
C:\Projects\gwt-windows-1.5.0\StockWatcher>applicationCreator -eclipse
StockWatcher -out StockWatcher
com.google.gwt.sample.stockwatcher.client.StockWatcher

It seems like a config thing. Any help appreciated.
thanks,
Anil

Ian Bambury

unread,
Aug 6, 2008, 10:45:18 PM8/6/08
to Google-We...@googlegroups.com
Or, more likely, mainPanel is null. Where did you get the code from?


 
2008/8/7 Anil <anil...@gmail.com>



--
Ian
http://examples.roughian.com
_______________________________________

Stuff the environment - Print this email
_______________________________________

Anil

unread,
Aug 9, 2008, 11:13:02 AM8/9/08
to Google Web Toolkit
Thank you for replying; in the debugger, I put a watch and see
" RootPanel.get("stockList")"= null

I am using GWT 1.5
The html file is in /public and is:



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=UTF-8">
<title>StockWatcher</title>
<script type="text/javascript" language="javascript"
src="com.google.gwt.sample.stockwatcher.StockWatcher.nocache.js"></
script>
</head>

<body>
<img src="images/GoogleCode.png" />
<h1>Stock Watcher</h1>
<div id="stockList"></div>
</body>
</html>

On Aug 6, 9:45 pm, "Ian Bambury" <ianbamb...@gmail.com> wrote:
> Or, more likely, mainPanel is null. Where did you get the code from?
>
> 2008/8/7 Anil <anil.r...@gmail.com>
>
>
>
>
>
> > Apparently there is a null pointer because root panel cannot find html
> > element 'stockList'.
>
> > [ERROR] Unable to load module entry point class
> > com.google.gwt.sample.stockwatcher.client.StockWatcher (see associated
> > exception for details)
> > java.lang.NullPointerException: null
> > at
>
> > com.google.gwt.sample.stockwatcher.client.StockWatcher.onModuleLoad(StockWatcher.java:
> > 67)
>
> > line 67 ----> RootPanel.get("stockList").add(mainPanel);
>
> > in the file StockWatcher.html:
>
> > <div id="stockList"></div>
>
> > I used the commands in the tutorial:
>
> > C:\Projects\gwt-windows-1.5.0\StockWatcher>projectCreator -eclipse
> > StockWatcher -out StockWatcher
> > C:\Projects\gwt-windows-1.5.0\StockWatcher>applicationCreator -eclipse
> > StockWatcher -out StockWatcher
> > com.google.gwt.sample.stockwatcher.client.StockWatcher
>
> > It seems like a config thing. Any help appreciated.
> > thanks,
> > Anil
>
> --
> Ianhttp://examples.roughian.com

Ian Bambury

unread,
Aug 9, 2008, 10:48:17 PM8/9/08
to Google-We...@googlegroups.com
Hi Anil,
 
If everything else was OK, then it would work, so something strange is happening elsewhere. If you want to send me a zip of the project, I'll have a look.
 
Ian

2008/8/9 Anil <anil...@gmail.com>

Nico

unread,
Sep 2, 2008, 6:07:09 PM9/2/08
to Google Web Toolkit
Hi Guys,

I am pretty much stuck on exactly the same problem and am not entirely
sure what's wrong. Anil or Ian......if you have figured out the
solution, could you post it up here please? I'd be very grateful!

Thanks,

Nico

On Aug 10, 3:48 am, "Ian Bambury" <ianbamb...@gmail.com> wrote:
> Hi Anil,
>
> If everything else was OK, then it would work, so something strange is
> happening elsewhere. If you want to send me a zip of the project, I'll have
> a look.
>
> Ian
>
> 2008/8/9 Anil <anil.r...@gmail.com>

Ian Bambury

unread,
Sep 2, 2008, 9:53:56 PM9/2/08
to Google-We...@googlegroups.com
As I remember, Anil never found the problem, he got fed up with it and started again from scratch and it worked - put it down to some caching problem, but didn't find out for sure.
 
He sent me the zip and I couldn't get it *not* to work, so I wasn't able to help. You can send your project if you like, but it might be the same situation.
 
Ian

2008/9/2 Nico <nic...@googlemail.com>



--
Ian

http://examples.roughian.com

====================================================
Internet communications are not secure and therefore I do not accept
legal responsibility for the contents of this message. Any views or
opinions do not necessarily represent what I really think unless
otherwise specifically stated and even then, I might still be lying.
This message may contain confidential privileged information, but if it
does, I've nicked it from someone else. If you have received this email
in error then tough, hit delete, and don't bother me about it, I really
don't care. Batteries not included. Contents may go up as well as down.
Shares may vary in size. May cause drowsiness, if affected, go to bed.
====================================================

Nico

unread,
Sep 3, 2008, 6:23:45 AM9/3/08
to Google Web Toolkit
Hi Ian

and thank you for the speedy reply. I have solved it by now.....it was
a combination of screen blindness, a late night and a missing
quotation mark in my html.

Nico

On Sep 3, 2:53 am, "Ian Bambury" <ianbamb...@gmail.com> wrote:
> As I remember, Anil never found the problem, he got fed up with it and
> started again from scratch and it worked - put it down to some caching
> problem, but didn't find out for sure.
>
> He sent me the zip and I couldn't get it *not* to work, so I wasn't able to
> help. You can send your project if you like, but it might be the same
> situation.
>
> Ian
>
> 2008/9/2 Nico <nico...@googlemail.com>

dacki Sun

unread,
Oct 10, 2013, 4:43:09 AM10/10/13
to google-we...@googlegroups.com, Google Web Toolkit, anil...@gmail.com
Hi!

I also had a NullPointerException but my problem was that I forgot to write the id in double quotes:

So I changed it from:
<div id=content></div>
To:
<div id="content"></div>

Maybe that helps somebody.

dacki

I had to simply change the code given by Google tutorial to something like this...

From:
// Associate the Main panel with the HTML host page.
RootPanel.get("stockList").add(mainPanel);

Something like this..
// Associate the Main panel with the HTML host page.
RootPanel.get().add(mainPanel);


Reply all
Reply to author
Forward
0 new messages