Custom URL path for Vaadin Application not working

public class MyVaadinUI extends UI {

    @WebServlet(value = "/testvaadin", asyncSupported = true)
    @VaadinServletConfiguration(productionMode = false, ui = MyVaadinUI.class)
    public static class Servlet extends SpringVaadinServlet {

                Vaadin UI class to use</description>




i am trying to integrate Vaadin into my Spring MVC Project. I have a demo that i was able to successfully integrate into my Project.

My Problem is the following. The entire application is now reachable over every urlpath in the application. That was not the goal for this application. I would actually like to have this application put behind a specific url. I already read the Book of Vaadin and tested out multiple things, but there was some strange behaviour with every change i have made. Changing the servlet mapping in the xml file (e.g.:/testvaadin) makes it that the content loads utterly slow and the content is loaded without any styles and anything. It is just Plain HTML. If i put the servlet mappings into the classfile than he starts telling me that the bootstrap.js file ist not available. Everything else is resulting in either 404 or bootstrap.js not found. I posted the Example Code above without the actual business logic, which i think is not relevant to the problem itself.

Which is the best way to go? XML or Annotation based? Which one does work for you? For me none of them are working properly except for /*

My pom looks like this:


Based on the quoted code and web.xml, I believe the problem is that you are trying to configure Vaadin servlets both with servlet 3.0 annotations (at a suitable sub-path) and in your web.xml (at the context root which is what captures all requests, and apparently with the wrong servlet class if used for more than just static resources - should be SpringVaadinServlet in your case).

If you do decide to serve your static resources (theme etc.) with a different servlet instance than the one configured with annotations, change the mapping in your web.xml to only serve /VAADIN/* . However, I would personally remove all Vaadin related parts in web.xml and use multiple paths (/testvaadin and /VAADIN) in the servlet annotation - you should be able to do this e.g. with the urlPatterns parameter as described

I tried both already. I tested it just with the annotations and also just with the xml definitions but both had the results that i described in the first post. I put them both in the example to show you how i did it for both of them but neither of them actually worked the way i expected.


What I did was to set the service url path like this.

SpringVaadinServlet servlet = new SpringVaadinServlet();
ServletRegistration.Dynamic dispatcher = servletContext.addServlet("vaadin", servlet);

The equivalent for you would be

    @WebServlet(value = "/testvaadin", asyncSupported = true)
    @VaadinServletConfiguration(productionMode = false, ui = MyVaadinUI.class)
    public static class Servlet extends SpringVaadinServlet {

It works as long as I use vaadin-spring version 1.0.0.beta3. The version 1.0.0 does not seem to support custom url paths…