Navigation Issue - Not navigating from LoginView to HomePage view on first

Hello Guys,
I am working on Vaadin UI application (Integrated through APIs). Following are some configurations we are using:

  • We are using Vaadin Session to store user token to interact with secure APIs.
  • Implemented MVP design pattern.
  • Using UI.navigate to navigate to another screen/view.

Everything is working fine except Login. I am struggling with issue when user successfully get token on login, Its fail to navigate to next view which is HomeView.Java (View) with Side Navigation implemented. Its happening only when I clean build everything and clear browser too.

To make successful login I have to refresh login page after first failed attempt then it navigate.

From logs, I checked It initialize the next view (HomeView.class) but don’t replace login with Home view on browser.

Code from where navigation happens:

  @Override
  public void onLoginComplete(UserProfileResponse userInfo) {
    LOGGER.debug("onLoginComplete");
    enableButton(loginButton);
    // Set User's Session Information
    mPresenter.setVaadinSessionAttribute(UserInfo.class, userInfo);

    // Update User locale in Session
    localeChange(userInfo);

	// Hide progress indicator
    mPresenter.getVaadinUI().accessSynchronously(() -> progressBar.setVisible(false));
	// Navigate to Home page
    navigateInternal(HomeView.class);

  }
  
  
    private void localeChange(UserProfileResponse user) {
    Executors.newSingleThreadExecutor().execute(new Runnable() {
      @Override
      public void run() {
        mPresenter.accessVaadinSession(() -> {
          String locale = user.getPreference() != null
              && !StringUtils.isEmpty(user.getPreference().getLocale()) ? user.getPreference()
              .getLocale() : null;
          if (locale != null && !mPresenter.getVaadinSession().getLocale().getLanguage()
              .equals(locale)) {
            if (Objects.equals(locale, Locale.GERMAN.toString()) && !mPresenter
                .getVaadinSession().getLocale().getLanguage().equals(Locale.GERMAN.toString())) {
              mPresenter.getVaadinSession().setLocale(Locale.GERMAN);
            } else {
              mPresenter.getVaadinSession().setLocale(Locale.ENGLISH);
            }
          }
        });
      }
    });
  }
  
  
  @Override
  public void navigateInternal(Class<? extends BaseFrame<?>> clazz) {
    mPresenter.accessVaadinUI(() -> {
      mPresenter.getVaadinUI().navigate(clazz);
    });
  }
  

Please help me out. Not able to get it fix.

I had that/or similar problem (deadlock) using accessSynchronously because the thread where I was calling navigatedidn’t have the lock VaadinSession#hasLock() returned false, so I replaced all them for access and it worked! (navi from LoginView → MainView)

jose luis romero:
I had that/or similar problem (deadlock) using accessSynchronously because the thread where I was calling navigatedidn’t have the lock VaadinSession#hasLock() returned false, so I replaced all them for access and it worked! (navi from LoginView → MainView)

Thanks for the response @jose luis
I’ll try replacing accessSynchronously with access only.