title: Vaadin Spring Boot: "Cannot access state in VaadinSession or UI without locking the session" when multiple users access UI
body: <p>I have a vaadin flow (13) application with spring boot. I have a VerticalLayout, annotated with <code>@UIScope</code> with multiple sub-layouts. The sub layouts are annotated with <code>@Scope("prototype")</code> and created via <code>ctx.getBean(SubUI.class, ...)</code>. Depending on selections and button clicks on the parent UI (VerticalLayout), the sub layouts are added or removed.</p>
  
  <p>That all works fine as long as I use the application alone (that's the reason why I found the error right now, after delivering the application to my customer for acceptantce test). They tested with multiple users. As long as one user works with the appliaction, everything works but as soon as a second user enters the UI (VerticalLayout), the following exception is thrown:</p>
  
  <pre><code>java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Cannot access state in VaadinSession or UI without locking the session.
      at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:1.8.0_202]
      at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[na:1.8.0_202]
      ...
  </code></pre>
  
  <p>I tried different annotations for my parent layout (@UIScope, @Scope("prototype"), @VaadinSessionScope) but non solves my error. </p>
  
  <p>I googled about the problem and found some threads, but none of them helped me to solve my problem. I am not really sure if the problem is caused by the scoping of my UIs/layouts or maybe by the data binding. In my sub layouts, data is bound using <code>Binder&lt;MyEntity&gt; binder = new Binder&lt;&gt;(MyEntity.class);</code> and <code>binder.forField(xxx).bind(MyEntity::getXY,MyEntity::setXY);</code>.</p>
  
  <p>Can someone maybe explain me, what my problem is? I would be really happy, because I need to deliver a fixed version for my customers test.</p>
  
  <p>Kind regards</p>