View Duplication on Browser Back Button Press

Hello, I did not manage to find a similar problem description on any of the forums, so I am posting it here.

I am using Navigator in my Vaadin-Spring application as stated

The problem arises when the view is changed from default to some other view and then changed back to the default (does not matter programmatically or by typing uri fragment directly in browser).

So when the default view loads, the view itself is doubled, i.e the window horizontally splits and I have two instances of the default view, and when again going to some other view and back, the previous doubled view is multiplied by 2, and so on and on…


See image attached.

Please note that it is not the case when typing the http://localhost:8080 address without any trailing /# (forward slash and hash symbols)

So the question is the following is there any workaround to get rid of /# or am I doing wrong?


Could you paste your UI.init method?

MainUI class with init method.

@SpringUI(path = “”)
public class MainUI extends UI {

private SpringViewProvider viewProvider;

protected void init(VaadinRequest vaadinRequest) {

       Navigator navigator = new Navigator(this, this);

       navigator.addViewChangeListener(new ViewChangeListener() {

              public boolean beforeViewChange(ViewChangeEvent viewChangeEvent) {
                     return true;

              public void afterViewChange(ViewChangeEvent viewChangeEvent) {


Thanks. I was expecting to see something strange in how the navigator and viewprovider are configured, but they seem to be all right. I don’t know what could be the reason. Are you accidentally adding somewhere a second Navigator or adding content manually in some listener to the UI?

Just checked everything, commented out other classes with views implementation and left some for bug reproducing purposes.


  1. The MainUI is posted above.

2. Default view SignInView

@SpringView(name = “”)
public class SignInView extends VerticalLayout implements View {

public void enter(ViewChangeListener.ViewChangeEvent viewChangeEvent) {"Sign In");


    AbsoluteLayout layout = new AbsoluteLayout();
    layout.addComponent(new Button("new"), "left: 50px; top: 50px;");


3. And the second view RegisterView

@SpringView(name = “register”)
public class RegisterView extends VerticalLayout implements View {

public void enter(ViewChangeListener.ViewChangeEvent viewChangeEvent) {"Register");


4. Vaadin servlet configuration

@WebServlet(value = “/*” ,asyncSupported = true)
@VaadinServletConfiguration(productionMode = true, ui = MainUI.class)
public class VaadinServlet extends SpringVaadinServlet {

5. Vaadin configuration

public class VaadinConfiguration {}

6. Vaadin widgetset

<?xml version="1.0" encoding="UTF-8"?>
    <inherits name="com.vaadin.DefaultWidgetSet"/>

    <inherits name="com.vaadin.addon.responsive.ResponsiveWidgetSet" />

7. WebContextInitializer (web.xml in java config)

public class WebContextInitializer implements WebApplicationInitializer {

public void onStartup(javax.servlet.ServletContext servletContext) throws ServletException {

    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    servletContext.addListener(new ContextLoaderListener(context));

private void registerServlet(ServletContext servletContext) {
    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("vaadin", SpringVaadinServlet.class);


Switching forward and back between default (“”) and register (“register”) view doubles the layout on the default view.

Maybe i did something wrong in configuration?