What I did wrong in tutorial?

I had looked through the video tutorial and I have try to write the same application. But it doesn’t work because a FilesystemContainer returns a NullPointerException:

There is my code:

import java.io.File;

import com.vaadin.Application;
import com.vaadin.data.util.FilesystemContainer;
import com.vaadin.ui.*;

public class DocumentmanagerApplication extends Application {
	
	FilesystemContainer docs = new FilesystemContainer(new File("C:\\Users\\andrey\\Documents"));
	Select select = new Select(null, docs);
	Label viewer = new Label("Select a doc", Label.CONTENT_RAW);
	
	@Override
	public void init() {
		Window mainWindow = new Window("Documentmanager Application");
		mainWindow.addComponent(select);
		mainWindow.addComponent(viewer);
		setMainWindow(mainWindow);
	}
}

I’m using Windows Vista, Eclipse STS and Apache Tomcat 7 as target runtime.
It seems to be wrong on Windows computer unfortunatly I can’t try out to execute it on linux machine.

Could somebody explain me what I did wrong?

Just a guess, but maybe your Java runtime doesn’t have access to the folder? Could you test it with another path?

Thanks for your answer!
I also tried out different paths but it still doesn’t work

From the source of FilesystemContainer, it looks like f.listFiles() is returning null. It can be the case only if f (a File) doesn’t point to a directory.
I think Vaadin should take care of this case in a more gracefully way… perhaps returning an empty list (not doing the Arrays.asList()).

I think the problem is that your application is running inside Tomcat, and such Web container usually restricts access to the filesystem outside of the Web application directory, for security reasons. So either you limit yourself to the webapp folders, or you find how to lift this restriction for your application (if possible).

Good catch!

I created a ticket
http://dev.vaadin.com/ticket/7698
that explains the actual bug.

Yes it seems like access denied error.
So, I had tried out the other way to run it
I created new directory c:\test and it is working!
But for others paths it still doesn’t work.

The bug report only covers error handling; you still have the issue of accessing the folder in the first place. If I were you, I’d try to isolate the issue. Make a simple Java app and test accessing any files and folders you don’t have access to from your Vaadin application. This way, you’ll know if the issue lies with Vaadin or your Java/OS configuration.