spring web-mvc and vaadin co-existing

I have read a bunch of threads here on the forum and have success in having Vaadin working in spring using Spring DispatchServlet to front the request. However, I am having trouble getting both to work at the same time. It comes down to the servlet-mapping in web.xml of org.springframework.web.servlet.DispatcherServlet.

In order to get Vaadin to working, I need the servlet-mapping to Spring’s org.springframework.web.servlet.DispatcherServlet to be “/*”.
But for spring web-mvc to work (setup by SpringRoo 1.1.2,), it needs to be “/”

Have any one had any luck having some url use Vaadin and some url serving regular spring-mvc?

Why pass the requests to the Vaadin application through DispatchServlet instead of directly to the Vaadin ApplicationServlet?

For Vaadin, you should not need to map “/" - you only need both “/VAADIN” and the Vaadin application path (e.g. “/myapp”) to point to the Vaadin ApplicationServlet. If the only application is a Vaadin servlet, "/” is a convenient “shortcut” for these, making the application visible at the root.

If you do the more specific mappings for Vaadin, you could then map other paths (“/*” or some part of it) to the DispatchServlet for Spring MVC.

I am tring to add vaadin to my Spring MVC project. Basically I need to take advantage of both jsp view and vaadin generated viewes.
I need to use jsp for frontend let’s say http://localhost:8080/HelloWorld/ and use vaadin for admin section http://localhost:8080/HelloWorld/admin.

URL: http://localhost:8080/HelloWorld/hello
The Spring Controller is working when I hit this

URL: http://localhost:8080/HelloWorld/admin
BUT vaadin controller give me following error with this

javax.servlet.ServletException: com.vaadin.server.ServiceException: com.vaadin.server.ServiceException: No UIProvider has been added and there is no “UI” init parameter.

/////////////////// web.xml //////////////////////

Web Application dispatcher org.springframework.web.servlet.DispatcherServlet 1 dispatcher / dispatcher-vad com.vaadin.server.VaadinServlet 1 dispatcher-vad /admin/*

​/////////////////// dispatcher-servlet.xml //////////////////////

<context:component-scan base-package=“com.programcreek.helloworld.controller” />


/WEB-INF/views/


.jsp


/////////////////// HelloWorldController.java //////////////////////
@Controller
public class HelloWorldController {
String message = “Welcome to Spring MVC!”;

@RequestMapping(“/hello”)
public ModelAndView showMessage(
@RequestParam(value = “name”, required = false, defaultValue = “World”) String name) {
System.out.println(“in controller”);

    ModelAndView mv = new ModelAndView("helloworld");
    mv.addObject("message", message);
    mv.addObject("name", name);
    return mv;
}

}

/////////////////// dispatcher-vad-servlet.xml //////////////////////

<?xml version="1.0" encoding="UTF-8"?>

<bean class="com.programcreek.helloworld.vad.controller.MyVaadinUI.MyConfiguration" />
<context:component-scan base-package="com.programcreek.helloworld.vad.controller" />

/////////////////// MyVaadinUI.xml //////////////////////
@Theme(“valo”)
@SpringUI(path = “”)
@SuppressWarnings(“serial”)
public class MyVaadinUI extends UI {

@WebServlet(urlPatterns = {"/admin/*", "/VAADIN/*"}, asyncSupported = true)
public static class Servlet extends SpringVaadinServlet {
}

// @WebListener
// public static class MyContextLoaderListener extends ContextLoaderListener {
// }
//
// @Configuration
// @EnableVaadin
// public static class MyConfiguration {
// }

@Override
protected void init(VaadinRequest request) {
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    setContent(layout);

    Button button = new Button("Click Me");
    button.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            layout.addComponent(new Label("Thank you for clicking"));
        }
    });
    layout.addComponent(button);
}

}

Here the pom file:

4.0.1.RELEASE org.springframework spring-core ${spring.version} org.springframework spring-web ${spring.version} org.springframework spring-webmvc ${spring.version} junit junit 3.8.1 test
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
    </dependency>

    <!-- Vaadin dependencies -->
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-spring</artifactId>
        <version>1.0.0</version>
    </dependency>
HelloWorld