Custom URL path for Vaadin Application not working

@Theme("demo")
@SpringUI
@SuppressWarnings("serial")
@Widgetset("com.journaldev.demoset")
public class MyVaadinUI extends UI {
    }


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

   <servlet>
        <servlet-name>vaadin-spring</servlet-name>
        <servlet-class>com.vaadin.server.VaadinServlet</servlet-class>
        <init-param>
            <description>
                Vaadin UI class to use</description>
            <param-name>UI</param-name>
            <param-value>com.journaldev.spring.Vaadin.MyVaadinUI</param-value>
        </init-param>
        <async-supported>true</async-supported>
    </servlet>

    <context-param>
        <param-name>productionMode</param-name>
        <param-value>false</param-value>
    </context-param>

    <servlet-mapping>
        <servlet-name>vaadin-spring</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>

Hi,

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.


https://github.com/tltv/gantt

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:

http://pastebin.com/cg7TSir5

Regards,
Akshay

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
here
.

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.

Hi,

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

SpringVaadinServlet servlet = new SpringVaadinServlet();
servlet.setServiceUrlPath("/v");
ServletRegistration.Dynamic dispatcher = servletContext.addServlet("vaadin", servlet);
dispatcher.addMapping("/v/*");
dispatcher.addMapping("/VAADIN/*");

The equivalent for you would be

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

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…