Webapp works for a single user, but then fails to reload or load for any other user

Hello Vaadin folks,

I have a small issue. I’m using Vaadin with Spring boot to make, what I believe, is a fairly straightforward application, there’s some buttons / textboxes / bells / whistles, but when the application is run a single user is able to load the UI, then if that user attempts to refresh the page, or any subsequent user attempts to load the page, it fails with a white screen.

The logs do not tell much of a story in this case…(the full stack trace does not mention my code at all)

2022-09-01 02:42:04.086 ERROR 610146 --- [io-8080-exec-27] c.v.flow.router.InternalServerError      : There was an exception while trying to navigate to ''

java.lang.IllegalStateException: 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

Is there something I’m doing wrong here?

My code in a nutshell looks like this:

@SpringBootApplication
public class SetDistributeApplication extends SpringBootServletInitializer {
    public static void main(String[] args) {
        SpringApplication.run(SetDistributeApplication.class, args);
    }

Which calls “mainView”:

 var main = new HorizontalLayout();
 main.setWidth("3800px");
    main.setHeight("4444px");
    main.getElement().setAttribute("theme", Lumo.DARK);
 ...
main.add(space1, leftPane, space2, middlePane, space3, rightPane);
add(main);

(space1, space2, space3, and leftPane/middlePane/rightPane are all VerticalLayout)
Any advice on this would be helpful.

Thanks,

Usually “Can’t move a node from one state tree to another” happens when you have a Vaadin Component that you’re trying to use in multiple different browser tabs. It could be a static reference to a Component or a component owned by a Spring / CDI Scope like @Singleton .

Generally all the components of the application itself are static, so that’d make sense, guess everything is about to become an object instead…

Wanted to loop back on this and see if there’s anything outlined about this in the documentation? I use 1 element which is static in my entire project (it’s required for waves hands reasons). If the whole rest of the UI is non-static why doesn’t just that 1 component break?

Fail early?

It’s not really documented perse but kinda common sense that you can’t share a component instance in a browser with a user in another browser, that would be a huge red flag. It could fail early, but the whole component tree / UI is just broken once a second user opens the UI because the component is still associated with the first UI

Are there any pieces of Vaadin which are inherently static? I have a component (button) complaining when I make it non-static and it’s reason is decidedly unhelpful…

Only VaadinIcon are partly static because but you normally use .create() go get a instance, anything else is definitely not static. Do you have an example and stack trace / exception? Does it complain on compile, runtime or unit-testing?

It’s just complaining that it’s static when there’s nothing static in the project other than the springboot initializer. The default route (“”) is called, which is non-static, I have a default constructor on that class (which is never instantiated), which calls another class, which class the method which creates a button.

So, something like this…

main.java

@SpringBootApplication
public class SetDistributeApplication extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication.run(SetDistributeApplication.class, args);
    }

}

MainView.java

@Route(value = "")
public class MainView extends VerticalLayout {
...
public MainView(){
...
--> Errors as static calling non-static -- var leftPane = LeftPane.getLeftPane(setHolder, imgHolder, csvUsersText, programLogs,
                    subscriptionUsers, users, subUsers, progressBar, progressBarLabel);

LeftPane.Java

public class LeftPane {
    public Component getLeftPane(){
    ...
    Component button = DistributeSetButton.getDistributeSetButton(progressBar, progressBarLabel,
                teaserImage,radioGroup,setPriceText, setNameText,setImageFiles, users,subUsers, programLogs);
    ...

DistributeSetButton.java

public class DistributeSetButton {
     Component getDistributeSetButton(
             ProgressBar progressBar, Div progressBarLabel, File teaserImage,
             RadioButtonGroup<String> radioGroup, TextField price, TextField name,
             ArrayList<File> setImages, ArrayList<User> users, ArrayList<User> subUsers,
             TextArea programLogs
     ){
        var b = new Button("Distribute Set");
        b.addClickListener(e ->{
            String setName = name.getValue();
            String setPrice = price.getValue();
            DistributeSet d = new DistributeSet();
            d.distributeSet(progressBar,progressBarLabel,teaserImage,radioGroup,
                    setPrice,setName,setImages, users,subUsers, programLogs);
        });

        return b;
    }
}

There’s just no mentions to static anywhere…

LeftPane.getLeftPane() and DistributedSetButton.getDistributeSetButton(…) looks like the culprit. That error is a java compile error saying what you doing isn’t possible

You can’t access a NON-static method from a static context. Using “LeftPane.” is static - it has to be “new LeftPane”

Ahhhh fuck

Thanks mate – second set of eyes. You’

re the best knoobie