Impossible NullPointer in ApplicationConnection (client side)

Before all I hope this is the right section for this discussion, if not I’m sorry. I’m getting a really strange error that brings me to think there’s a problem in the javascript interpreter of my browser. Here the software versions I’m using:

  • Vaadin 6.8.13;
  • Firefox 27.0.1.

What happens: rendering of the page is incomplete, and if I refresh the page (F5) the refresh completes as expected. Compiling the widgetset with the DETAILED flag and doing a little debugging with Firebug I found a “TypeError: this$static is null” exception. this$static is a method parameter that is actually null in the stacktrace, but if I go to the caller of the method, the passed variable is correctly defined!!! The method where the error happens in the source code is a Command anonymous object created in the ApplicationConnection line 1059 (here a piece of the code):

        if (json.containsKey("timings")) {
            serverTimingInfo = json.getValueMap("timings");

        Command c = new Command() {
            public void execute() {
                VConsole.dirUIDL(json, configuration);

                if (json.containsKey("locales")) {
                    // Store locale data
                    JsArray<ValueMap> valueMapArray = json

The compiled javascript code of the caller is (sorry for the poor formatting):

$intern_295 in json && com_vaadin_terminal_gwt_client_ApplicationConfiguration_$addComponentMappings__Lcom_vaadin_terminal_gwt_client_ApplicationConfiguration_2Lcom_vaadin_terminal_gwt_client_ValueMap_2Lcom_vaadin_terminal_gwt_client_WidgetSet_2V(this$static.com_vaadin_terminal_gwt_client_ApplicationConnection_configuration, json[$intern_295]
$intern_296 in json && (this$static.com_vaadin_terminal_gwt_client_ApplicationConnection_serverTimingInfo = json[$intern_296]
c = new com_vaadin_terminal_gwt_client_ApplicationConnection$8_ApplicationConnection$8__Lcom_vaadin_terminal_gwt_client_ApplicationConnection_2V(this$static, json, start, jsonText);
com_vaadin_terminal_gwt_client_ApplicationConfiguration_widgetsLoading == 0?com_vaadin_terminal_gwt_client_ApplicationConnection$8_$execute__Lcom_vaadin_terminal_gwt_client_ApplicationConnection$8_2V(c):(java_util_LinkedList_$addLast__Ljava_util_LinkedList_2Ljava_lang_Object_2V(com_vaadin_terminal_gwt_client_ApplicationConfiguration_callbacks, c) , true); 

In the last line “com_vaadin_terminal_gwt_client_ApplicationConnection$8_$execute__Lcom_vaadin_terminal_gwt_client_ApplicationConnection$8_2V(c)” is called, and in the stacktrace c is correctly defined, but inside the function that starts with:

function com_vaadin_terminal_gwt_client_ApplicationConnection$8_$execute__Lcom_vaadin_terminal_gwt_client_ApplicationConnection$8_2V(this$static){
var $e0, cd, change, changes, detail, e, error, html, i, length, meta, n, newSize, oldSize, paintable, paintable$iterator, pid, repaintAll, sizeUpdatedWidgets, timedRedirect, uidl, updatedWidgets, url, valueMapArray, widget;
com_vaadin_terminal_gwt_client_VConsole_dirUIDL__Lcom_vaadin_terminal_gwt_client_ValueMap_2Lcom_vaadin_terminal_gwt_client_ApplicationConfiguration_2V(this$static.com_vaadin_terminal_gwt_client_ApplicationConnection$8_val$json, this$static.com_vaadin_terminal_gwt_client_ApplicationConnection$8_this$0.com_vaadin_terminal_gwt_client_ApplicationConnection_configuration);
if ($intern_318 in this$static.com_vaadin_terminal_gwt_client_ApplicationConnection$8_val$json) {
valueMapArray = this$static.com_vaadin_terminal_gwt_client_ApplicationConnection$8_val$json[$intern_318]
repaintAll = false;
meta = null; 

The parameter this$static (that should take the value of c) is undefined! And to add to the strange behaviour, if I run “com_vaadin_terminal_gwt_client_ApplicationConnection$8_$execute__Lcom_vaadin_terminal_gwt_client_ApplicationConnection$8_2V(c)” in the console it runs correctly!

Please if you can give me a clue on how I can solve this problem would be nice.

Thank you.

Some questions:

  1. Is this error only popping up when you’re accessing the application with this exact Browser?
  2. Is this error coming from Standard Vaadin Code or a Custom component/add-on/… ?
  3. Does the same error pop up when you open another Vaadin application in this Browser? (like the Vaadin sampler or a demo)
  1. During the tests some testers got the same symptoms in chrome, but I didn’t debug it there, if needed I can run the same debug it in chrome as well, even if I’m not familiar with the developer tools there;
  2. Standard Vaadin Code;
  3. I tried the sampler a bit there, but I didn’t see any remarkable error.

Ok I run the debug in Chrome, and the error that I receive is in the same place of the code but it’s different! The error this time is:

TypeError: Cannot set property 'com_vaadin_terminal_gwt_client_ui_layout_ChildComponentContainer_alignment' of null at com_vaadin_terminal_gwt_client_ui_layout_ChildComponentContainer_$setAlignment__Lcom_vaadin_terminal_gwt_client_ui_layout_ChildComponentContainer_2Lcom_vaadin_terminal_gwt_client_ui_AlignmentInfo_2V

I’ll further investigate the case.

You could also try out other Vaadin versions. Maybe it was a bug which was fixed in 6.8.14 or it was one that was accidentialy in the 13 version and is not present in earlier ones.
You said you were able to open the Vaadin sampler without any errors so it doesn’t seem to be a bug which is still present in earlier versions.

To make sure that it isn’t something coming from your code you could try creating a simple Vaadin 6.8.13 project and open it with your Browser.

I don’t know much about the inner works of Vaadin so i can’t really help you identifying where the exact problem comes from.
I can just help you (and everyone who reads this) get a better understanding when this error pops up.

Ok I’ve cornered the problem, but I don’t know the internals of vaadin so I can’t explain how it happens. The problem is that it tries to set the alignment of a CustomComponent I defined, but the code can’t locate the container of this component. The error happens in the class VOrderedLayout (standard vaadin), in the method:

    protected void updateAlignmentsAndExpandRatios(UIDL uidl,
            ArrayList<Widget> renderedWidgets) {

        alignments = uidl.getMapAttribute("alignments");

         * UIDL contains a map of paintable ids to expand ratios

        expandRatios = uidl.getMapAttribute("expandRatios");
        expandRatioSum = -1.0;

        for (int i = 0; i < renderedWidgets.size(); i++) {
            Widget widget = renderedWidgets.get(i);
            String pid = client.getPid(widget.getElement());

            ChildComponentContainer container = getComponentContainer(widget);

            // Calculate alignment info

            // Update expand ratio

The method getComponentContainer(widget) returns null. Internally the container is taken from a map:

protected ChildComponentContainer getComponentContainer(Widget child) {
        return widgetToComponentContainer.get(child);

So the problem is that there is a discrepancy between this map and the rendered widgets. I’ll continue my debugging, but at this point an advice from someone familiar with the internals would be appreciated.


Thanks for pointing me in the right direction.