nyg nyg - 1 year ago 92
Java Question

Custom SpringVaadinServlet not detected

I'm trying to use a custom

in my Vaadin app (that uses Spring Boot). Here's a sample app, in which the
is not detected. I've read the Spring Vaadin tutorial but still can't get it to work. Here's the code (I have no XML conf):

public class VaadinSb2Application {

public static void main(String[] args) {
SpringApplication.run(VaadinSb2Application.class, args);

public class AppConfig {}

public class MyUI extends UI {

private static final long serialVersionUID = 1L;

protected void init(VaadinRequest request) {
setContent(new Label("Welcome!"));

@WebServlet(urlPatterns = "/*", name = "MyServlet", asyncSupported = true)
public static class MyServlet extends SpringVaadinServlet {

private static final long serialVersionUID = 1L;

public MyServlet() {
System.out.println("servlet constr");

protected void servletInitialized() throws ServletException {
System.out.println("servlet init");

Here are links to the Vaadin documentation:

I use Spring Boot 1.4.2 and the latest Vaadin version.

Answer Source

When you use Spring Boot with Vaadin you should not register a servlet by using the @WebServlet annotation. The following should work to the override default Vaadin Spring Boot servlet:

public class MySpringVaadinServlet extends SpringVaadinServlet {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download