VaadinSpring UIProvider


I am trying to get a LoginScreen. Therefore i want to map two UIs to the root path:

LoginUI = /* (this is the initial UI)
MainUI = /* (This is UI ui after successful login in)

I have a lot of problems get this to work with spring-boot:

My UIProvider is ignored!

public class MyUIProvider extends UIProvider
public Class<? extends UI> getUIClass(UIClassSelectionEvent event) {
 return VaadinSession.getCurrent().getAttribute(LoginUI.LOGIN_USER_ID) == null ? LoginUI.class : MainUI.class;


public UI createInstance(UICreateEvent event) {
UI instance = new LoginUI();
return instance;


@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = LoginUI.class)
public class MySpringVaadinServlet extends SpringVaadinServlet implements SessionInitListener {

private static final Logger LOG = LoggerFactory.getLogger(CustomSpringVaadinServlet.class);

MyUIProvider uiProvider;


public void init(ServletConfig servletConfig) throws ServletException {
AutowireCapableBeanFactory ctx =
((ApplicationContext) getServletContext().getAttribute("applicationContext"))

protected void servletInitialized() throws ServletException {

public void sessionInit(SessionInitEvent event) throws ServiceException {


Hi @eggme
What is exactly the goal?
If you’re using Spring Security, you could also use the PostSuccessfulAuthenticationHandler. This way you have still one location in which you can decide to redirect the user to the desired URL. Otherwise I would go for having the application path set in the UI as
@SpringUI(path = “/app/*”)
and map the login UI to another one like
@SpringUI(path = “/login”).
When the login goes through, then redirect to “/app/”. But I ignore how you are securing the URL’s right now in terms of authorization.
Hope it helps