Session Expired on Login

I’m trying to implement a Login into my VaadinApp. I Use your standard Login-Form. Here’s a Codesnippet from within my Vaadin Application Class.


init(){
...
final LoginForm login = new LoginForm();
        login.setWidth("-1px");
        login.addListener(new LoginForm.LoginListener() {
            public void onLogin(LoginForm.LoginEvent event) {
                String pw = event.getLoginParameter("password");
                String username = event.getLoginParameter("username");
                try {
					authenticate(username, pw);
					login.setComponentError(null);
					
				} catch (Exception e) {
					login.setComponentError(new UserError("Bad username or password"));
				}
            }
        });
...
}
public void authenticate( String login, String password) throws Exception
    {
		UserAccount user = userManager.findUser(login);		
		if (user != null && password.equals(user.getPassword())){
			loadProtectedResources();
			return;
		}
		throw new Exception("bad username or password!");
    }

Now the weird thing:
Whenever i try to login, i get a Session Expiration. I’ve read that another guy had a similar problem and solved it by installing Sessionguard, that hasn’t done the trick for me. I’ve been able to do a dirty workaround so that login works anyway, but this big red box is highly annoying, so I was hoping somebody might be able to help a little bit here.

Greetings, Sascha.

Hi guys,

I found the error. In case anybody else comes across a similar problem, here’s what happened:

any call of addWindow() after it has been run will cause the session to expire (or at least it did so in my case). I did that within loadProtectedResources(), which i didnt list here.

so to prevent this, add your windows on startup once and dont remove them.

greetings,
Sascha.