GWT using SDM throws error at app startup

215 views
Skip to first unread message

dhoffer

unread,
Aug 30, 2014, 1:37:09 PM8/30/14
to google-we...@googlegroups.com
I'm getting the following error after SDM compiles my app and trying to load it. What's causing this? Seems the compiler is generating invalid JS?  How can I resolve this?  I can't debug my app anymore.


SEVERE: (TypeError) __gwt$exception: <skipped>: Cannot read property 'view' of undefined com.google.gwt.core.client.JavaScriptException: (TypeError) __gwt$exception: <skipped>: Cannot read property 'view' of undefined: at 
Unknown.$getView(adloader-0.js@21:31671) 
Unknown.setBookingSheetRowData_0(adloader-0.js@16:104761) 
Unknown.gridRowsChanged_1(adloader-0.js@17:104543) 
Unknown.updateGridRowsWithChildrenAdded(adloader-0.js@14:104468) 
Unknown.$addChildModelRows(adloader-0.js@39:103808) 
Unknown.LoadAdsPrepareModel_0(adloader-0.js@3:103898) 
Unknown.$onModuleLoadImpl(adloader-0.js@25:89933) 
Unknown.$onModuleLoad_2(adloader-0.js@5:89837) 
Unknown.init_1(adloader-0.js@19:17385) 
Unknown.apply_9(adloader-0.js@23:7805) 
Unknown.entry0(adloader-0.js@14:7895) 
Unknown.anonymous(adloader-0.js@16:7855) 
Unknown.gwtOnLoad(adloader-0.js@19:118446) 
Unknown.anonymous(adloader-0.js@167:118452)

I'm using GWT 2.6.1



Jens

unread,
Aug 30, 2014, 2:58:38 PM8/30/14
to google-we...@googlegroups.com
GWT often (if not always) transforms methods that are not overridden into static methods. Such static methods begin with a $ sign.

In your stack trace you can see Unknown.$getView is causing the exception with message "Can not read property 'view' of undefined". That basically means in your Java code you have called null.getView() because GWT transforms this into something like $getView(instance) { return instance.view; } with instance being "undefined" (= null).

So it is either a bug in your app which can cause NullPointer exceptions or you have found a very rare case which causes the GWT compiler to produce wrong JS. 

-- J.

David Hoffer

unread,
Aug 30, 2014, 6:28:32 PM8/30/14
to Google Web Toolkit
Hum...I'm not entirely clear how that maps to the java code.  As I follow that stack trace I think this comes down to this code:

public class LoadAdsPrepareGridPresenter {

    private final ILoadAdsPrepareGridModel model;
    private final ILoadAdsPrepareGridView view;

    public LoadAdsPrepareGridPresenter(final ILoadAdsPrepareGridModel model,
                                       final ILoadAdsPrepareGridView view) {
        this.model = model;
        this.view = view;

        model.addListener(new ILoadAdsPrepareGridModelListener() {
            @Override
            public void gridRowsChanged() {
                view.setBookingSheetRowData(
                        model.getGridBookingSheetRowModels());
            }
        });

So are you saying that the member variable 'view' is null?  This is injected into the class so it's not possible for it to be null...and it's final.

Or are you saying that view is not null but it's somehow calling getView()?  I don't think this is the case but I wanted to be sure.  (In my java code the view doesn't have any method called 'getView()' I'm assuming 'getView()' is something generated by GWT to get the view variable.).

-Dave



--
You received this message because you are subscribed to a topic in the Google Groups "Google Web Toolkit" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-web-toolkit/1lsSTQluIxE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-web-tool...@googlegroups.com.
To post to this group, send email to google-we...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Jens

unread,
Aug 31, 2014, 5:43:35 AM8/31/14
to google-we...@googlegroups.com
The stack trace says the error is inside setBookingSheetRowData().

But just don't be afraid to look at the JS code. Open Chrome Dev Tools, go to the sources tab, open adloader-0.js (and wait a bit as it is maybe a large file), hit ctrl + g and enter the line numbers of the stack trace. For setBookingSheetRowData() it is line number 104761 and for $getView it is 31671. The JS code will look relatively similar to your Java code, as GWT does not do any optimizations.
Then you can set a breakpoint to see what is going on. You can also set a breakpoint on "java" level by going to the sources tab, hit ctrl + o to open LoadAdsPrepareGridPresenter.java provided by source maps and then set a breakpoint for view.setBookingSheetRowData(model.getGridBookingSheetRowModels());


-- J.

David Hoffer

unread,
Aug 31, 2014, 11:09:12 PM8/31/14
to Google Web Toolkit
My bad.  Somehow I almost convinced myself that GWT was wrapping my 'view' variable with a getter called getView that I didn't see what the stack trace was really telling me. (If I would have called my variable x this would have been obvious.)  Yes you are right there was a case where a widget that does have a getView method could be called at startup where the instance is null.  I have corrected this and all works well.  I had tried to load the JS file in notepad++ but it's so large it crashed the editor, thanks for the debugging tips & link to the Chrome shortcuts I will check this out as well. 

-Dave
 


--
Reply all
Reply to author
Forward
0 new messages