What causes com.google.gwt.core.client.JavaScriptException, and how to trace it?

14,815 views
Skip to first unread message

dduck

unread,
Jan 15, 2010, 4:45:05 AM1/15/10
to Google Web Toolkit
In a relatively large project I sometimes get this exception:

Class: com.google.gwt.core.client.JavaScriptException
Message:
(TypeError): Result of expression 'a' [null] is not an object.
line: 1513
sourceId: 4996591080
sourceURL: http://worm:8080/myShopInstall/gwt-results-app/F89E790362E6204FFEC75F28511A554C.cache.html
expressionBeginOffset: 18437
expressionCaretOffset: 18438
expressionEndOffset: 18440

I am unsure as to how I can trace or otherwise diagnose the cause, as
this seems to be impossible to catch using the usual Java tools (try/
catch).

Any suggestions?

Regards,
Anders

LEDUQUE Mickaël

unread,
Jan 15, 2010, 9:39:14 AM1/15/10
to Google Web Toolkit
Y(ou'll probably only have this kind of exception in javascript
compiled app, so you won't be able to use hosted/devmode to inspect
it. I'd probably compile the application with style=DETAILED and use
tools like firebug (Firefox) or webkit developer tools (chrome/safari)
to debug that.
Of course, if this really is a big application, it may take some
resources to trace into DETAILED javascript (I know for example
Firebug has some problems with really big js files).

John V Denley

unread,
Jan 21, 2010, 6:19:57 AM1/21/10
to Google Web Toolkit
I have a similar problem with a compiled GWT javascript, but it only
fails in IE.

Im not sure where in eclipse to set "style=DETAILED" and even if I
did, is there a firebug dev tool for debugging javascript in IE?

I dont mind taking some time to figure out how to set the
"style=DETAILED", but only if there is some way to debug the problem
once ive done it!

Thanks,
John

On Jan 15, 2:39 pm, LEDUQUE Mickaël <mledu...@gmail.com> wrote:
> Y(ou'll probably only have this kind ofexceptioninjavascript
> compiled app, so you won't be able to use hosted/devmode to inspect
> it. I'd probably compile the application with style=DETAILED and use
> tools like firebug (Firefox) or webkit developer tools (chrome/safari)
> todebugthat.
> Of course, if this really is a big application, it may take some

> resources to trace into DETAILEDjavascript(I know for example

Joe Cole

unread,
Jan 21, 2010, 7:53:19 AM1/21/10
to Google Web Toolkit
This can happen in devmode. I found one today - it was an exception in
a deferred command while manipulating an xml document.
To debug in devmode is relatively easy - simply debug before it breaks
and step through.

In web mode I have encountered a few of these as well. Here is our
approach:

1. Maintain a global action list which tracks most (e.g. Actions.add
("actionname"))
2. In your uncaught exception handler, pull in the action list and
send that back to the server which then logs the result and sends
emails etc.
We also send back the entire page dom structure as an attachment to
the email so we can take a look at the data on the page at the time of
the error.

This has enabled us to find out which customer, what they were doing
and the timing of what they did - then we can easily replicate it in
devmode.

Hope this helps

On Jan 15, 10:45 pm, dduck <anders.johansen.a...@gmail.com> wrote:
> In a relatively large project I sometimes get this exception:
>
> Class: com.google.gwt.core.client.JavaScriptException
> Message:
> (TypeError): Result of expression 'a' [null] is not an object.
> line: 1513
> sourceId: 4996591080

> sourceURL:http://worm:8080/myShopInstall/gwt-results-app/F89E790362E6204FFEC75F...

dduck

unread,
Jan 21, 2010, 9:14:01 AM1/21/10
to Google Web Toolkit
Well, using Safari I can now spot the place where the exception is
thrown in the generated JavaScript, but I have no way to relate that
to the Java code that I put into the GWT compiler.

Any clues as to how I do that?

Regard,
Anders

John V Denley

unread,
Jan 21, 2010, 9:44:35 AM1/21/10
to Google Web Toolkit
I finally bit the bullet, and started commenting out huge chunks of my
code, and running the application to see if that got rid of the
problem...

After a few hours of this, I finally narrowed it down to the following
(and similar) line of code:

daygrid.getColumnFormatter().setWidth(col, "0px");

As soon as I set this to "1px" rather than "0px" the javascript error
went away.

for you dduck, the way forward would be to do as leduque suggests
above and set the compile time flag for style to "detailed" and that
should give you a much better idea where the error is, you might find
the following link useful:
http://code.google.com/webtoolkit/doc/1.6/FAQ_DebuggingAndCompiling.html#Why_is_my_GWT-generated_JavaScript_gibberish?

Id still like to know how to set this setting via eclipse, which im
sure is very simple for someone who knows!

Thanks,
John

g p

unread,
Jan 21, 2010, 10:34:39 AM1/21/10
to google-we...@googlegroups.com
When you press the compile button in Eclipse, there is a drop down menu called: Output Style. One of the options there is the detailed. I suppose that would do the trick ... 

2010/1/21 John V Denley <johnv...@googlemail.com>

John Denley

unread,
Jan 21, 2010, 10:54:03 AM1/21/10
to google-web-toolkit
I dont get that option, where is this "compile" button you refer to? I always use the "run as", there is a "Compile GWT project" under that, but it doesnt give me any options, it just starts compiling!

Incidentally, I have now deployed this "fixed for IE" version, and online, it doesnt work, even though locally it works fine! sigh.....

2010/1/21 g p <ghos...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


dduck

unread,
Jan 26, 2010, 7:11:29 AM1/26/10
to Google Web Toolkit

On 21 Jan., 15:44, John V Denley <johnvden...@googlemail.com> wrote:
> for you dduck, the way forward would be to do as leduque suggests
> above and set the compile time flag for style to "detailed" and that
> should give you a much better idea where the error is, you might find

> the following link useful:http://code.google.com/webtoolkit/doc/1.6/FAQ_DebuggingAndCompiling.h...

I have done so, but the debugging still points to a piece of
JavaScript that does not have a clear correspondence to the original
Java code :(

Regards,
Anders

dduck

unread,
Jan 26, 2010, 7:41:07 AM1/26/10
to Google Web Toolkit

On 26 Jan., 13:11, dduck <anders.johansen.a...@gmail.com> wrote:
> I have done so, but the debugging still points to a piece of
> JavaScript that does not have a clear correspondence to the original
> Java code :(

Specifically it points to this line:

function Y$(a){var b;if(a.Z()){return KK(new IK,Wob)}else{b=lJ(new
fJ,Ohb+a._()+Xob);b.d=true;oJ(b,vV(new _$,a));return b}}

The error is: "java.lang.IndexOutOfBoundsException: Can't get element
58"

Regards,
Anders

dduck

unread,
Jan 26, 2010, 8:55:55 AM1/26/10
to Google Web Toolkit
...and another, this time the one I am actually after:

Class: com.google.gwt.core.client.JavaScriptException
Message:
(TypeError): Result of expression 'a' [null] is not an object.

line: 1520
sourceId: 4968015904
sourceURL: http://worm:8080/myShopInstall/gwt-results-app/5DF30FE3D0E594F4B64889C27BA79632.cache.html
expressionBeginOffset: 18742
expressionCaretOffset: 18743
expressionEndOffset: 18745

Line 1520 in the file looks like this:

function ZF(a){var b;b=PP(new MP,a.g);while(b.b<b.c.d-1){RP(b);TP(b)}}

Djabi

unread,
Jan 26, 2010, 10:15:13 AM1/26/10
to Google Web Toolkit
BTW, Your code stills looks like compiled with -style obfuscated.

On Jan 26, 6:55 am, dduck <anders.johansen.a...@gmail.com> wrote:
> ...and another, this time the one I am actually after:
>
> Class: com.google.gwt.core.client.JavaScriptException
> Message:
> (TypeError): Result of expression 'a' [null] is not an object.
> line: 1520
> sourceId: 4968015904

> sourceURL:http://worm:8080/myShopInstall/gwt-results-app/5DF30FE3D0E594F4B64889...

dduck

unread,
Jan 26, 2010, 11:21:49 AM1/26/10
to Google Web Toolkit

On 26 Jan., 16:15, Djabi <george.djaba...@gmail.com> wrote:
> BTW, Your code stills looks like compiled with -style obfuscated.

You are right.

Thought I had fixed it, but hadn't.

Here is the unobfuscated code:

function com_google_gwt_user_client_ui_Panel_
$clear__Lcom_google_gwt_user_client_ui_Panel_2V(this$static){
var it;
it = com_google_gwt_user_client_ui_WidgetCollection$WidgetIterator_
$WidgetCollection
$WidgetIterator__Lcom_google_gwt_user_client_ui_WidgetCollection
$WidgetIterator_2Lcom_google_gwt_user_client_ui_WidgetCollection
$WidgetIterator_2(new com_google_gwt_user_client_ui_WidgetCollection
$WidgetIterator, this
$static.com_google_gwt_user_client_ui_ComplexPanel_children);
while (it.com_google_gwt_user_client_ui_WidgetCollection
$WidgetIterator_index <
it.com_google_gwt_user_client_ui_WidgetCollection$WidgetIterator_this
$0.com_google_gwt_user_client_ui_WidgetCollection_size - 1) {
com_google_gwt_user_client_ui_WidgetCollection$WidgetIterator_
$next__Lcom_google_gwt_user_client_ui_WidgetCollection
$WidgetIterator_2Lcom_google_gwt_user_client_ui_Widget_2(it);
com_google_gwt_user_client_ui_WidgetCollection$WidgetIterator_
$remove__Lcom_google_gwt_user_client_ui_WidgetCollection
$WidgetIterator_2V(it);
}
}


Error points to line starting with "it = com_google<..>"

Error message is:
"(TypeError): Result of expression 'this$static' [null] is not an
object."

John Denley

unread,
Jan 26, 2010, 2:51:36 PM1/26/10
to google-web-toolkit
This is beyond anything Ive come across before, sorry I cant help anymore, though it looks like i did manage to push you in the right direction!....

good luck figuring it out...

2010/1/26 dduck <anders.joh...@gmail.com>

dduck

unread,
Jan 27, 2010, 4:07:09 AM1/27/10
to Google Web Toolkit

On 26 Jan., 20:51, John Denley <johnvden...@googlemail.com> wrote:
> This is beyond anything Ive come across before, sorry I cant help anymore,
> though it looks like i did manage to push you in the right direction!....
>
> good luck figuring it out...

I finally did.

The root cause was a programming error on my behalf, where an object
might be null if some methods were invoked in the wrong order. This
introduced a nasty timing-dependant error.

The actual subject of mu posting is still unresolved, however: It is
very hard to figure out the area of the original Java code responsible
for an exception thrown at runtime. I understand that a better stack
trace mechanism is in the works, but obviously it is not yet part of
the production branch of GWT. In the mean time we are left to our most
ancient tools, the printf and our naked brain :)

Regards, and thanks for the help all
Anders

dduck

unread,
Jan 27, 2010, 7:09:53 AM1/27/10
to Google Web Toolkit

On 27 Jan., 10:07, dduck <anders.johansen.a...@gmail.com> wrote:
> I understand that a better stack
> trace mechanism is in the works, but obviously it is not yet part of
> the production branch of GWT. In the mean time we are left to our most
> ancient tools, the printf and our naked brain :)

Turns out it is in the production branch, only not as a default.

To enable, add these two lines to the module file:

<set-property name="compiler.emulatedStack" value="true"/>
<set-configuration-property
name="compiler.emulatedStack.recordFileNames" value="true"/>

This will enable stack traces on this format:

<...>
Unknown.Hh(JsArrayString.java:42)
Unknown.Pf(StackTraceCreator.java:366)
Unknown.IN(SpinnerWhileRequestingViewer.java:129)
Unknown.CL(TrappableCommand.java:35)
Unknown.iL(TrappableCommand.java:24)
Unknown.Zw(CommandExecutor.java:310)
Unknown.mx(Duration.java:29)
Unknown.lf(Timer.java:141)
Unknown.anonymous(Timer.java:60)
Unknown.Tg(Impl.java:146)
Unknown.anonymous(Impl.java:56)
<...>

These stack traces would have saved me at least a man week, if only I
had known. Guess you have to R *all* TFM to be sure :D

Regards,
Anders

Reply all
Reply to author
Forward
0 new messages