'How to deploy Vaadin 22 to Tomcat 8.5

I downloaded a Vaadin22 starter-app using this link. Everything works fine using the embedded Server.

But deploying to Tomcat 8.5.35 raises the following error in localhost.log (I tried also with V14 and V23, same issue):

java.lang.IllegalStateException: The application Lookup instance is not found in the interface com.vaadin.flow.server.VaadinContext instance. It means that the container has not executed Lookup initialization code: so either the container is not Servlet 3.0 compatible or project configuration is broken.
    at com.vaadin.flow.server.startup.ApplicationConfiguration.lambda$get$0(ApplicationConfiguration.java:58)
    at com.vaadin.flow.server.VaadinServletContext.getAttribute(VaadinServletContext.java:73)

As a result the servlet is undeployed.

To deploy to production I switched to war-packaging in pom.xml and executed the build with mvn clean package -Pproduction. Afterwards I copied the .war-File manually to the Webapps-Location.

The error message mentions Servlet 3.0 compatibility. But this Tomcat documentation clearly states that Tomcat 8.5 supports Servlet 3.1.

Any help is appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source