Vaadin Spring Boot integration - custom servlet


I need to get rid of the vaadin red error message when someone tries to interact with the application
after session timeout. According to book and few forum posts I would need to extends vaadin
servlet to do that. Since I use spring boot integration - how do I go about that ? I tried to simply
create a new servlet and return it as a bean in my application configuration class but that does not seem
to work properly. Any suggestions please ?



public ServletRegistrationBean servletRegistrationBean() {
SpringVaadinServlet servlet = new SpringVaadinServlet() {

        private static final long serialVersionUID = 1L;

        class MySystemMessagesProvider implements SystemMessagesProvider {

            private static final long serialVersionUID = 1L;

            public SystemMessages getSystemMessages(SystemMessagesInfo systemMessagesInfo) {
                CustomizedSystemMessages messages = new CustomizedSystemMessages();                    
                messages.setCommunicationErrorCaption("Error - bla bla bla");

                return messages;

        public void servletInitialized() throws ServletException {
            getService().addSessionInitListener(new SessionInitListener() {

                private static final long serialVersionUID = 1L;

                public void sessionInit(SessionInitEvent event) throws ServiceException {
                    event.getService().setSystemMessagesProvider(new MySystemMessagesProvider());
    return new ServletRegistrationBean(servlet, "/UI/*");


​That seems to be working properly !