Opening a stream in a window problem in 6.4.0

I have some working code that is no longer working in 6.4.0. I’ve redeployed my app with the new Vaadin jar and restarted my app server, but no go. Basically, there is a server process that drops a file that I read using StreamResource and open in a sub window as below:

...blah, blah, do a bunch of stuff and create outFile...

final StreamResource stream = new StreamResource(new StreamResource.StreamSource() {

                @Override
                public InputStream getStream() {
                    try {
                        return new FileInputStream(outFile);
                    } catch (FileNotFoundException ex) {
                        ex.printStackTrace();
                    }
                    return null;
                }
            }, outFile.getAbsolutePath(), app);
            Window w = new Window("Blast results for " + read.getName());
            w.setWidth("60%");
            w.setHeight("50%");
            VerticalLayout layout = (VerticalLayout) w.getContent();
            layout.setSpacing(true);
            layout.setMargin(true);
            layout.setSizeUndefined();
            w.addListener(new Window.CloseListener() {

                @Override
                public void windowClose(CloseEvent e) {
                    queryFile.delete();
                    outFile.delete();
                }
            });
            w.open(stream);
            app.getMainWindow().addWindow(w);

However, in 6.3.4, this works. When in 6.4.0, I get the following output from the Vaadin?debug applet. The file is created correctly on the server side, and if I comment out the w.open(stream) line, I do get the window.

com.google.gwt.core.client.JavaScriptException: (TypeError): Cannot call method ‘Ld’ of null stack: TypeError: Cannot call method ‘Ld’ of null at Object.h3b [as Ld]
(http://localhost:8080/OceanExplorer/VAADIN/widgetsets/com.vaadin.terminal.gwt.DefaultWidgetSet/E62C7CCDC270C6968D9C0965B2FF6C79.cache.html:4380:1073) at o1b (http://localhost:8080/OceanExplorer/VAADIN/widgetsets/com.vaadin.terminal.gwt.DefaultWidgetSet/E62C7CCDC270C6968D9C0965B2FF6C79.cache.html:4377:1344) at Object.D1b [as Ld]
(http://localhost:8080/OceanExplorer/VAADIN/widgetsets/com.vaadin.terminal.gwt.DefaultWidgetSet/E62C7CCDC270C6968D9C0965B2FF6C79.cache.html:1654:19) at thb (http://localhost:8080/OceanExplorer/VAADIN/widgetsets/com.vaadin.terminal.gwt.DefaultWidgetSet/E62C7CCDC270C6968D9C0965B2FF6C79.cache.html:4372:538) at Jfb (http://localhost:8080/OceanExplorer/VAADIN/widgetsets/com.vaadin.terminal.gwt.DefaultWidgetSet/E62C7CCDC270C6968D9C0965B2FF6C79.cache.html:4285:556) at Hgb (http://localhost:8080/OceanExplorer/VAADIN/widgetsets/com.vaadin.terminal.gwt.DefaultWidgetSet/E62C7CCDC270C6968D9C0965B2FF6C79.cache.html:4193:352) at xC (http://localhost:8080/OceanExplorer/VAADIN/widgetsets/com.vaadin.terminal.gwt.DefaultWidgetSet/E62C7CCDC270C6968D9C0965B2FF6C79.cache.html:3626:140) at Object.aD [as $b]
(http://localhost:8080/OceanExplorer/VAADIN/widgetsets/com.vaadin.terminal.gwt.DefaultWidgetSet/E62C7CCDC270C6968D9C0965B2FF6C79.cache.html:2659:57) at XMLHttpRequest. (http://localhost:8080/OceanExplorer/VAADIN/widgetsets/com.vaadin.terminal.gwt.DefaultWidgetSet/E62C7CCDC270C6968D9C0965B2FF6C79.cache.html:2897:68) at Gn (http://localhost:8080/OceanExplorer/VAADIN/widgetsets/com.vaadin.terminal.gwt.DefaultWidgetSet/E62C7CCDC270C6968D9C0965B2FF6C79.cache.html:3121:49) type: non_object_property_call arguments: Ld,
Processing time was 31ms for 935 characters of JSON
Referenced paintables: 39

What do I need to do to fix this problem? I’d love to take advantage of some of the new Vaadin 6.4 features.

Thanks,
Chris

As a further test to make sure all is well with the stream, I did this:

w.open(stream, "_new");

I now get my file opened properly, but in a new window as expected. I need the content of this file to be in the window as before, though. Something weird is definitely afoot.

Thanks,
Chris

Try recompiling the widgetset using “Pretty” or “Detailed” mode (Project preferences → Vaadin if using Eclipse) and you might get a more sensible error message than “Cannot call method ‘Ld’ of null stack:”. Then it should be easier to say what is going on.

Great idea, Artur. I use NetBeans so it won’t be so easy for me, but I’ll look up how to accomplish this and report back.

Thanks,
Chris

OK, I followed the instructions
here
to compile my own widgetset (which is empty). For others, I only had to add the following to the style lines to the compile-widgetset target

<target name="compile-widgetset" depends="init, widgetset-init, generate-widgetset">
...        
<java classname="com.google.gwt.dev.Compiler" failonerror="yes" fork="yes" maxmemory="256m">
    <arg value="-style"/>
    <arg value="PRETTY"/>
    <arg value="-war" />
...
</target>

Using ?debug, I now see the following errors when trying to set the stream in the window

com.google.gwt.core.client.JavaScriptException: (TypeError): Cannot call method ‘updateFromUIDL’ of null stack: TypeError: Cannot call method ‘updateFromUIDL’ of null at Object.updateFromUIDL_40 [as updateFromUIDL]
(http://localhost:8080/OceanExplorer/VAADIN/widgetsets/edu.vcu.csbc.oceanexplorer.widgetset.MyAppWidgetSet/1DD78105582BF48414EB8CD7B7541CCC.cache.html:37869:15) at $updateFromUIDL_13 (http://localhost:8080/OceanExplorer/VAADIN/widgetsets/edu.vcu.csbc.oceanexplorer.widgetset.MyAppWidgetSet/1DD78105582BF48414EB8CD7B7541CCC.cache.html:36914:9) at Object.updateFromUIDL_39 [as updateFromUIDL]
(http://localhost:8080/OceanExplorer/VAADIN/widgetsets/edu.vcu.csbc.oceanexplorer.widgetset.MyAppWidgetSet/1DD78105582BF48414EB8CD7B7541CCC.cache.html:37039:3) at $execute (http://localhost:8080/OceanExplorer/VAADIN/widgetsets/edu.vcu.csbc.oceanexplorer.widgetset.MyAppWidgetSet/1DD78105582BF48414EB8CD7B7541CCC.cache.html:13170:19) at $handleReceivedJSONMessage (http://localhost:8080/OceanExplorer/VAADIN/widgetsets/edu.vcu.csbc.oceanexplorer.widgetset.MyAppWidgetSet/1DD78105582BF48414EB8CD7B7541CCC.cache.html:12309:23) at $onResponseReceived (http://localhost:8080/OceanExplorer/VAADIN/widgetsets/edu.vcu.csbc.oceanexplorer.widgetset.MyAppWidgetSet/1DD78105582BF48414EB8CD7B7541CCC.cache.html:12900:43) at $fireOnResponseReceived (http://localhost:8080/OceanExplorer/VAADIN/widgetsets/edu.vcu.csbc.oceanexplorer.widgetset.MyAppWidgetSet/1DD78105582BF48414EB8CD7B7541CCC.cache.html:2910:5) at Object.onReadyStateChange (http://localhost:8080/OceanExplorer/VAADIN/widgetsets/edu.vcu.csbc.oceanexplorer.widgetset.MyAppWidgetSet/1DD78105582BF48414EB8CD7B7541CCC.cache.html:3118:51) at XMLHttpRequest. (http://localhost:8080/OceanExplorer/VAADIN/widgetsets/edu.vcu.csbc.oceanexplorer.widgetset.MyAppWidgetSet/1DD78105582BF48414EB8CD7B7541CCC.cache.html:11812:13) at entry0 (http://localhost:8080/OceanExplorer/VAADIN/widgetsets/edu.vcu.csbc.oceanexplorer.widgetset.MyAppWidgetSet/1DD78105582BF48414EB8CD7B7541CCC.cache.html:438:23) type: non_object_property_call arguments: updateFromUIDL,

I’ve attached the pretty gwt html. Please have a look and let me know what you think.

In the meantime, I’ve switched over to using an Embedded (TYPE.BROWSER) to show the file I’m dropping (which itself is an html file), and this has actually proved quite useful since I can put it in a panel and wrap other useful info around it. Anyway, the window stream opening is definitely strange.

Thanks,
Chris
11340.html (1.44 MB)

Ok, I missed the little word “sub” in the first post. You cannot open a resource in a sub window, only in browser level windows. Because Window represents both a sub window and a browser level window in Vaadin 6 there is API that only applies to one of them (even though sub windows should not allow you to open resources). This will change in Vaadin 7. If you want to show a resource in a sub window or anywhere else in your application you should add it using an Embedded component.

Sounds very strange that it worked somehow in 6.3.x

Makes sense to me, but very strange indeed. Embedded is definitely the better way to go for me anyway and it took this problem for me to sort that out (still new to Vaadin) in my own head.

Thanks for the help.

Chris