When I log in from two accounts to my vaadin app I get this error message
Can't move a node from one state tree to another. If this is intentional, first remove the node from its current state tree by calling removeFromTree
Learn more about calling the error: Logging in with Google OAuth2 When logging in to the application from user A's account, everything works fine, as soon as I log in to the application from user B's account at the same time, I get an error message
As I understand from the message, I have common interface objects that I have to clean up or create new ones for each incoming user
Maybe there is some tutorial on implementing an application that is used by several users at the same time or something similar?
Vaadin does not allow sharing components. This is true inside a single UI state tree (the component will be moved instead of being visible on two locations).
And this is especially true for sharing components between different UI state trees. The result is the error you got there.
Prime suspects for (accidentally) sharing components are:
static
variables, or things, that are only there
once, like enum
s; usually things, developers only want to keep one
thing around or "save" resources (e.g. don't put
VaadinIcons.COGS.create()
in your enum
. Just use
VaadinIcons.COGS
and then call the .create()
on it, whenever you
add one to the UI.@UIScope
should be fine (this also
includes "harmless" scopes like prototype
.Note also, that the problem is always with the component, not with
what the component itself uses outside of other components. So it's OK
to have a prototype:d TextField
using a singleton I18NService
.
Those kind of errors are quite sneaky, since developers tend to only ever test with one session/UI and tend to creep up once the app goes live. And the given error message is practically useless outside an application with a debugger attached to it.