4

I have a web page in Vaadin 10 that process files. How do I make different user have different sessions? When I try to open my page in different browsers to process files I get:

java.lang.IllegalStateException: Cannot access state in VaadinSession or UI without locking the session.

I can't find any useful information or tutorial in official documentation. Currently I look through Baker App - but I can't find there anything about sessions either.

Vaadin Version: 10.0.0.rc3
Spring Boot Version: 2.0.3.RELEASE
Java: 1.8

John
  • 467
  • 1
  • 6
  • 23
  • Have you tried with 10.0.1? – cfrick Jul 13 '18 at 07:30
  • @cfrick yep, same thing. – John Jul 13 '18 at 07:55
  • 1
    It is (to me) not really clear: do you get this errors in the bakery application or in your application processing files? And if in your application, please provide the relevant code to show the actual problem. Different users have different sessions and if you get that error with the bakery, there is something fundamentally broken. – cfrick Jul 13 '18 at 08:25

1 Answers1

4

Actually, it is mentioned in the documentation. Take a look at its Javadoc here. Based on that document, you need to access session like this:

String someValue = null;
session.lock();
try {
    someValue = session.getAttribute("SomeKey");
} finally {
    session.unlock();
}

The complete Javadoc of different versions of Vaadin framework can be seen here.

By the way, I suggest you use the latest version of Vaadin flow which is 10.0.1

Mehdi Javan
  • 1,081
  • 6
  • 25
  • 7
    Also note, that the proper way to manipulate the UI state is via `UI.access`. See https://github.com/vaadin/framework/blob/master/documentation/advanced/advanced-push.asciidoc#accessing-ui-from-another-thread – cfrick Jul 13 '18 at 09:20