Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop vaadin stealing all url-patterns (and play nicely with spring mvc)

Tags:

java

vaadin

I have a vaadin application and I am trying to provide some REST Urls provided by spring MVC alongside - my web.xml is below. I only get 404s at /info - it seems like Vaadin steals all the url patterns.

If I remove Vaadin, I can reach /info and get content at that url. How to I get them to play nicely together?

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml
    </param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<context-param>
    <description>Vaadin production mode</description>
    <param-name>productionMode</param-name>
    <param-value>false</param-value>
</context-param>

<servlet>
    <servlet-name>Vaadin Application Servlet</servlet-name>
    <servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
    <!-- replace standard applicationServlet with the ICEpush one -->
    <!--<servlet-class>org.vaadin.artur.icepush.ICEPushServlet</servlet-class>-->
    <init-param>
        <description>Vaadin application class to start</description>
        <param-name>application</param-name>
        <param-value>myapp.vaadin.MyVaadinApp</param-value>
    </init-param>
    <init-param>
        <param-name>widgetset</param-name>
        <param-value>myapp.gwt.MyAppWidgetSet</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>Vaadin Application Servlet</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>Vaadin Application Servlet</servlet-name>
    <url-pattern>/VAADIN/*</url-pattern>
</servlet-mapping>

<servlet>
    <servlet-name>info</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>info</servlet-name>
    <url-pattern>/info</url-pattern>
</servlet-mapping>
like image 315
Tom Avatar asked Feb 25 '23 17:02

Tom


1 Answers

The url-pattern for the Vaadin servlet is /* which is a wild-card for everything so that servlet will handle every request. One option is to narrow the urls for the Vaadin servlet to something more specific than /*.

like image 69
Robby Pond Avatar answered Feb 27 '23 20:02

Robby Pond