Skip to content

Unmatched DispatcherServlet requests fail with "No servlet with name 'springServlet'" when the app registers the Vaadin servlet itself and vaadin.urlMapping isn't set #27244

In review

Description

@totally-not-ai

Description of the bug

VaadinServletConfiguration is applied whenever RootMappedCondition matches, and that condition only looks at the vaadin.urlMapping property: when the property isn't set, the Vaadin servlet is assumed to be mapped to /*. The configuration then adds vaadinRootMapping, a catch-all (/**) handler mapping, to every DispatcherServlet that uses the context. It forwards unmatched requests to a servlet named springServlet, which is the name VaadinMVCWebAppInitializer and the Spring Boot auto-configuration give the Vaadin servlet when they register it at /vaadinServlet/* behind a root-mapped DispatcherServlet.

An application that registers the servlets itself doesn't match that assumption. This happens with a plain Spring (non-Boot) app that:

  • imports VaadinServletConfiguration, directly or through @EnableVaadin,
  • registers the Vaadin SpringServlet itself in its own WebApplicationInitializer, e.g. at /gui/*, under another name,
  • registers its own DispatcherServlet, e.g. at /api/*,
  • doesn't set vaadin.urlMapping, because it never uses that property to register anything.

Then any request to the DispatcherServlet that no controller handles, e.g. /api/blah, is routed to the forwarding controller instead of producing a 404, and fails with a 500:

jakarta.servlet.ServletException: No servlet with name 'springServlet' defined in web.xml
  at org.springframework.web.servlet.mvc.ServletForwardingController.handleRequestInternal(ServletForwardingController.java:127)
  at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:177)
  at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:49)
  at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
  ...

The only workaround today is to set vaadin.urlMapping to a non-root value, even though nothing reads it to register a servlet in this setup.

Reported in https://vaadin.com/forum/t/vaadin-web-application-deployment-assumptions/180271/3

Expected behavior

When there is no Vaadin servlet to forward to, Vaadin shouldn't take over unmatched DispatcherServlet requests: /api/blah should give the normal 404.

Possible fix: have RootExcludeHandler (or the vaadinRootMapping bean) return no handler when the servlet context has no servlet registered under the forwarding controller's name (ServletContext.getServletRegistration("springServlet") == null). The root-mapped setups that Vaadin registers itself keep working, because there the servlet exists. A stricter alternative is to also skip it when the DispatcherServlet handling the request isn't mapped to /.

Minimal reproducible example

  1. Create a Spring MVC application without Spring Boot, with a root configuration annotated with @EnableVaadin (or importing VaadinServletConfiguration), and don't set vaadin.urlMapping.
  2. In your own WebApplicationInitializer, register new SpringServlet(context, false) under a name other than springServlet at /gui/*, and a DispatcherServlet at /api/*.
  3. Deploy and request /api/does-not-exist. Expected 404; actual 500 with the exception above.

Versions

  • Vaadin / Flow version: 25.x (main)

Working on behalf of Olli

Activity

  1. changed the title [-]Unmatched DispatcherServlet requests fail with "No servlet with name 'springServlet'" when Vaadin registers its servlets elsewhere and vaadin.urlMapping isn't set[/-] [+]Unmatched DispatcherServlet requests fail with "No servlet with name 'springServlet'" when the app registers the Vaadin servlet itself and vaadin.urlMapping isn't set[/+] on Nov 24, 2026
  2. totally-not-ai commented on Nov 24, 2026

    @totally-not-ai
    ContributorAuthor

    Triage: confirmed bug. A plain Spring app that registers the Vaadin servlet itself gets a 500 instead of a 404 for every DispatcherServlet request no controller handles.

    • Affects: apps that import VaadinServletConfiguration (e.g. via @EnableVaadin), register SpringServlet themselves under a name other than springServlet, and don't set vaadin.urlMapping.
    • Affected branches: main and all maintained branches (24.9, 25.x) have the same code.
    • Regression: no — long-standing behavior.
    • Severity: moderate — wrong status code and a server error logged; real routes still work.
    • Impact: low — only hand-written servlet registration without Spring Boot.
    • Workaround: set vaadin.urlMapping to a non-root value such as /gui/*. It only disables the catch-all mapping in this setup.
    • Root cause: without vaadin.urlMapping, Vaadin assumes it registered a root-mapped servlet named springServlet and forwards all unmatched requests to it, without checking that the servlet exists.
    • Next step: draft PR fix(spring): skip root forwarding when Vaadin servlet is not registered #27245 makes the catch-all mapping step aside when that servlet isn't registered.
    Root cause
    • RootMappedCondition treats a missing vaadin.urlMapping as /*, so VaadinServletConfiguration is applied.
    • Its vaadinRootMapping bean maps /** at lowest-but-one precedence to a ServletForwardingController for springServlet.
    • That name exists only when Vaadin registers the servlet (VaadinMVCWebAppInitializer, Spring Boot auto-configuration). Otherwise ServletForwardingController finds no named dispatcher and throws ServletException.
  3. archiecobbs commented on Nov 24, 2026

    @archiecobbs
    Contributor
  4. added theissue type on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions