NullPointerException when @Autowiring in AppUI.init (just on standalone/pro


I face problem I cannot solve.
vaadin 8.1.5
springboot 1.5.4
vaading4spring 2.0.0.RELEASE (tried also 0.0.7.RELEASE, same error)

My code:

public class AppUI extends UI {

private MainScreen mainScreen;

protected void init(VaadinRequest request) {

final Navigator navigator = new Navigator(this, mainScreen.getContainer());

public class MainScreen extends MainScreenDesign implements AppScreen {...}
public class LimsApplication extends SpringBootServletInitializer {

public RestTemplate restTemplate() {
return new RestTemplate();

public static void main(String args) {, args);

protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(LimsApplication.class);

Works when running on embedded tomcat via command spring-boot:run, application works,
but throws NullPointerException on production server or standalone, when deploying as WAR. (my packaging in pom.xml is WAR in both cases)

Both Tomcats are 8.5.15.

2017-12-06 17:52:10.918 INFO 4336 --- [nio-8080-exec-7]
 o.v.spring.servlet.Vaadin4SpringServlet : Custom Vaadin4Spring servlet initialization completed
2017-12-06 17:52:11.356 ERROR 4336 --- [nio-8080-exec-8]
 com.vaadin.server.DefaultErrorHandler :

java.lang.NullPointerException: null
at sk.geneton.lims.frontend.ui.AppUI.init(
at com.vaadin.ui.UI.doInit(

Attached you can find complete tomcat logs when starting on embedded tomcat and standalone tomcat.

I guess it’s something with vaadin and spring sessions, but cannot find solution.

Hope somebody helps me.

Michal Lichvar

39501.txt (50.4 KB)
39502.txt (157 KB)

Ok, we found the problem, it was in code below (static class at the end of AppUI, used to change system messages)

@WebServlet(urlPatterns = "/*", name = "CustomUIServlet", asyncSupported = true)
@VaadinServletConfiguration(ui = AppUI.class, productionMode = false)
public static class CustomUIServlet extends VaadinServlet {

   protected void servletInitialized() throws ServletException {

      CustomizedSystemMessages messages = new CustomizedSystemMessages();

      // Internal Error (after JWT expired exception) overwritten to Connection Timeout
      messages.setInternalErrorCaption("Connection timeout");
      messages.setInternalErrorMessage("Take note of any unsaved data, and <u>click here</u> or press ESC to continue.");

      getService().setSystemMessagesProvider(e -> messages);


solution: change VaadinServlet to SpringVaadinServlet :smiley: