flow: Including flow server as a dependency breaks custom spring webmvc configuration

Description of the bug

Merely including flow-server as a dependency breaks custom spring config via @EnableWebMvc

Minimal reproducible example

Here’s a custom webmvc example for serving static resources

@Configuration
@Lazy(false)
@EnableWebMvc
class WebConfiguration : WebMvcConfigurer {
    override fun addResourceHandlers(registry: ResourceHandlerRegistry) {
        super.addResourceHandlers(registry.apply {
            // resource handler for static swagger-ui
            addResourceHandler("/rs/**")
                .addResourceLocations("classpath:/webapp/rs/")

            // resource handler for images
            addResourceHandler("/img/**")
                .addResourceLocations("classpath:/webapp/img/")

            // resource handler for icons
            addResourceHandler("/icon/**")
                .addResourceLocations("classpath:/webapp/icon/")
        });
    }

    override fun addViewControllers(registry: ViewControllerRegistry) {
        super.addViewControllers(
            registry.apply {
                // redirect(s) to index-html
                addRedirectViewController("/rs", "/rs/index.html")
                addRedirectViewController("/rs/", "/rs/index.html")
                addRedirectViewController("/rs/internal", "/rs/internal/index.html")
                addRedirectViewController("/rs/internal/", "/rs/internal/index.html")
            }
        )
    }
}

Expected behavior

Custom webmvc config should not be adversely affected. Also, when not including vaadin-spring or excluding its auto configuration, vaadin should not interfere with spring at all.

Actual behavior

Just by including flow-server as a dependency custom webmvc setup stops working and fetching a static resource will yield:

Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported]
15:07:18.006 [mt-6] DEBUG o.s.web.servlet.DispatcherServlet - Completed 405 METHOD_NOT_ALLOWED

Versions:

- Vaadin / Flow version: 17.0.1
- Java version: 14.0.2
- OS version: macos-10.15.6
- Browser version (if applicable): -
- Application Server (if applicable): -
- IDE (if applicable): IJ

Sidenotes

  • This issue did not occur with vaadin-14.2.0
  • Spring configurations / controllers in non-spring artifact flow-server seem to be misplaced

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 34 (22 by maintainers)

Commits related to this issue

Most upvoted comments

This indeed is related to our Vaadin for TypeScript feature, the solution could be that we register the VaadinConnectController conditionally (when there is an Endpoint). I will make a PR for this.

Good point. Living on the edge makes on expect that any download would use SNAPSHOT versions =_=