Vaadin session initialized twice

  1. Download https://vaadin.com/start/v14 - Full Stack App
  2. Changed ConfigureUIServiceInitListener
  @Override
  public void serviceInit(ServiceInitEvent event) {
    final AtomicInteger sessionsCount = new AtomicInteger(0);

    final VaadinServletService servletService = (VaadinServletService) event.getSource();
    final VaadinServlet vaadinServlet = servletService.getServlet();
    getLogger().info("Service init for {} of type {} with id {}", vaadinServlet.getServletName(), vaadinServlet.getClass().getName(),
        System.identityHashCode(vaadinServlet));

    final VaadinService vaadinService = event.getSource();
    vaadinService.addSessionInitListener(
        sessionInitEvent -> {
          getLogger().info("New Vaadin session created. Current count is: {}", sessionsCount.incrementAndGet());
        });
    vaadinService.addSessionDestroyListener(
        sessionDestroyEvent -> getLogger().info("Vaadin session destroyed. Current count is {} ", sessionsCount.decrementAndGet()));

    event.getSource().addUIInitListener(uiEvent -> {
      final UI ui = uiEvent.getUI();
      ui.add(new OfflineBanner());
      ui.addBeforeEnterListener(this::beforeEnter);
    });
  }
  1. Why is the session initialized twice?
====================================================================
2020-03-15 11:16:47.420  INFO 44696 --- [nio-8080-exec-1]
 c.g.a.a.s.ConfigureUIServiceInitListener : Service init for springServlet of type com.vaadin.flow.spring.SpringServlet with id 62182667
2020-03-15 11:16:47.441  INFO 44696 --- [nio-8080-exec-3]
 c.vaadin.flow.spring.SpringInstantiator  : The number of beans implementing 'I18NProvider' is 0. Cannot use Spring beans for I18N, falling back to the default behavior
2020-03-15 11:16:47.441  INFO 44696 --- [nio-8080-exec-3]
 c.g.a.a.s.ConfigureUIServiceInitListener : New Vaadin session created. Current count is: 1
2020-03-15 11:16:47.460  INFO 44696 --- [nio-8080-exec-1]
 c.g.a.a.s.ConfigureUIServiceInitListener : New Vaadin session created. Current count is: 2

Hi, I got the same issue. I solved checking this tutorial https://vaadin.com/learn/tutorials/java-web-app/login-screen
I guess that I had some misconfiguration with spring security and pom dependencies

I’m dealing with this https://vaadin.com/forum/thread/17382025/logout were you able to solve it?

Regards

I do not remember exactly
There was kind of a problem with @push annotation - play with her and her options