java.lang.IllegalArgumentException Window with name 'sms' already....

What’s the reason for the following error message:

how can I clear the session of this name?

Suppose the user logs out, but decides to log back in, I need to be able to clear the application name so user can login again.

You probably use addWindow() in your application to add new application-level windows. Apparently you have given a window a specific name, “sms”, and then tried to add another window with the same name. The window name must be unique.

You may want to have the window name automatically generated, in which case you should leave it as null.

hi Marko,
so ‘sms’ in this case refers to a LoginWindow class which is reached initially and after LogoutWindow is called.

Can you point me to source code which shows the proper way to build a multiple window/paged Vaadin app?

There’s some examples
here
, which are about the same as in the Book. I think Book has a couple others as well.

Your problem is probably caused by setting an explicit window name with setName(“sms”). The window objects are not automatically removed from the application when closed, so the next time you call addWindow(), it is still there. You can remove the window object in a window close handler with getApplication().removeWindow(), as follows:

class MyPopup extends Window {
    public MyPopup() {
        super("Popup Window");
        addComponent(new Label("I just popped up to say hi!"));
        
        final Window popup = this;
        addListener(new CloseListener() {
            @Override
            public void windowClose(CloseEvent e) {
                getApplication().removeWindow(popup);
            }
        });
    }
}

The simpler way is not to set a fixed name at all, unless it is really needed for some reason, but let it be automatically generated, that is, not call setName().

However, I’m a bit worried about using an application-level window for login and logout. Application-level windows have some problems, such as the one above and that you need polling to update the main window. The normal practice is to use sub-windows for login, or just login/logout views in the main window (see for example
this example
).