vaadin / hilla

Build better business applications, faster. No more juggling REST endpoints or deciphering GraphQL queries. Hilla seamlessly connects Spring Boot and React to accelerate application development.
https://hilla.dev
Apache License 2.0
904 stars 57 forks source link

Error "Neither PathPatterns nor String patterns condition" when migrate 24.3.13 to 24.4.1 #2545

Closed khergalant closed 3 months ago

khergalant commented 3 months ago

Description of the bug

When I start my application, there is an error at startup :

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'filterChain' defined in class path resource [fr/mypackage/config/SecurityConfig.class]: Failed to instantiate [org.springframework.security.web.SecurityFilterChain]: Factory method 'filterChain' threw exception with message: Error creating bean with name 'mvcHandlerMappingIntrospector' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Neither PathPatterns nor String patterns condition at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:648) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1337) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1167) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:337) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:975) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:962) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:624) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456) at org.springframework.boot.SpringApplication.run(SpringApplication.java:335) at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:149) at fr.mypackage.Application.main(Application.java:45) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50) Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.SecurityFilterChain]: Factory method 'filterChain' threw exception with message: Error creating bean with name 'mvcHandlerMappingIntrospector' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Neither PathPatterns nor String patterns condition at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:177) at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:644) ... 23 common frames omitted Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcHandlerMappingIntrospector' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Neither PathPatterns nor String patterns condition at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1788) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:600) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:337) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1240) at org.springframework.security.config.annotation.web.configurers.CorsConfigurer$MvcCorsFilter.getMvcCorsFilter(CorsConfigurer.java:116) at org.springframework.security.config.annotation.web.configurers.CorsConfigurer.getCorsFilter(CorsConfigurer.java:94) at org.springframework.security.config.annotation.web.configurers.CorsConfigurer.configure(CorsConfigurer.java:73) at org.springframework.security.config.annotation.web.configurers.CorsConfigurer.configure(CorsConfigurer.java:41) at org.springframework.security.config.annotation.AbstractConfiguredSecurityBuilder.configure(AbstractConfiguredSecurityBuilder.java:376) at org.springframework.security.config.annotation.AbstractConfiguredSecurityBuilder.doBuild(AbstractConfiguredSecurityBuilder.java:330) at org.springframework.security.config.annotation.AbstractSecurityBuilder.build(AbstractSecurityBuilder.java:38) at fr.mypackage.config.SecurityConfig.filterChain(SecurityConfig.java:159) at fr.mypackage.config.SecurityConfig$$SpringCGLIB$$0.CGLIB$filterChain$13(<generated>) at fr.mypackage.config.SecurityConfig$$SpringCGLIB$$FastClass$$1.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:258) at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:339) at fr.mypackage.config.SecurityConfig$$SpringCGLIB$$0.filterChain(<generated>) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:140) ... 24 common frames omitted Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Neither PathPatterns nor String patterns condition at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1788) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:600) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:337) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:665) at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1388) at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:368) at org.springframework.web.servlet.handler.HandlerMappingIntrospector.initHandlerMappings(HandlerMappingIntrospector.java:130) at org.springframework.web.servlet.handler.HandlerMappingIntrospector.afterPropertiesSet(HandlerMappingIntrospector.java:118) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1835) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1784) ... 49 common frames omitted Caused by: java.lang.IllegalArgumentException: Neither PathPatterns nor String patterns condition at org.springframework.util.Assert.isTrue(Assert.java:111) at org.springframework.web.servlet.mvc.method.RequestMappingInfo.<init>(RequestMappingInfo.java:165) at org.springframework.web.servlet.mvc.method.RequestMappingInfo.combine(RequestMappingInfo.java:355) at com.vaadin.hilla.EndpointControllerConfiguration.prependEndpointPrefixUrl(EndpointControllerConfiguration.java:236) at com.vaadin.hilla.EndpointControllerConfiguration$1$1.registerHandlerMethod(EndpointControllerConfiguration.java:195) at com.vaadin.hilla.EndpointControllerConfiguration$1$1.registerHandlerMethod(EndpointControllerConfiguration.java:182) at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lambda$detectHandlerMethods$2(AbstractHandlerMethodMapping.java:298) at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721) at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.detectHandlerMethods(AbstractHandlerMethodMapping.java:296) at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.processCandidateBean(AbstractHandlerMethodMapping.java:265) at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:224) at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:212) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:239) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1835) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1784) ... 62 common frames omitted

Expected behavior

Application should start without error

Minimal reproducible example

Migrate java project from 24.3.13 to 24.4.1

Versions

mcollovati commented 3 months ago

The error seems to originate here com.vaadin.hilla.EndpointControllerConfiguration.prependEndpointPrefixUrl(EndpointControllerConfiguration.java:236)

I'll transfer the issue to the Hilla repository for further investigation

Artur- commented 3 months ago

Before trying anything else, check and see if 24.4.2 resolves the issue as there is a classpath / dependency conflict issue in 24.4.1. Not sure it is out yet though but coming real soon

khergalant commented 3 months ago

Same with 24.4.3 But all Hilla-*.jar dependencies are in 24.4.1

[INFO] +- com.vaadin:vaadin-spring-boot-starter:jar:24.4.2:compile [INFO] | +- com.vaadin:vaadin-spring:jar:24.4.1:compile [INFO] | | +- com.vaadin:flow-server:jar:24.4.1:compile [INFO] | | | +- com.vaadin.servletdetector:throw-if-servlet3:jar:1.0.2:compile [INFO] | | | +- com.vaadin.external.gwt:gwt-elemental:jar:2.8.2.vaadin2:compile [INFO] | | | +- org.apache.commons:commons-fileupload2-jakarta:jar:2.0.0-M1:compile [INFO] | | | | - org.apache.commons:commons-fileupload2-core:jar:2.0.0-M1:compile [INFO] | | | +- com.helger:ph-css:jar:7.0.2:compile [INFO] | | | | - com.helger.commons:ph-commons:jar:11.1.5:compile [INFO] | | | +- org.ow2.asm:asm:jar:9.7:compile [INFO] | | | - com.vaadin.external:gentyref:jar:1.2.0.vaadin1:compile [INFO] | | +- com.vaadin:flow-push:jar:24.4.1:compile [INFO] | | | - com.vaadin.external.atmosphere:atmosphere-runtime:jar:3.0.5.slf4jvaadin1:compile [INFO] | | +- com.vaadin:flow-client:jar:24.4.1:compile [INFO] | | +- org.springframework:spring-webmvc:jar:6.1.8:compile [INFO] | | +- org.springframework:spring-websocket:jar:6.1.8:compile [INFO] | | - org.reflections:reflections:jar:0.10.2:compile [INFO] | | - org.javassist:javassist:jar:3.28.0-GA:compile [INFO] | +- com.vaadin:hilla:jar:24.4.1:compile [INFO] | | +- com.vaadin:hilla-endpoint:jar:24.4.1:compile [INFO] | | | +- com.vaadin:hilla-engine-core:jar:24.4.1:compile [INFO] | | | | +- com.vaadin:hilla-parser-jvm-core:jar:24.4.1:compile [INFO] | | | | | +- io.github.classgraph:classgraph:jar:4.8.171:compile [INFO] | | | | | - com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.17.1:compile [INFO] | | | | +- com.vaadin:hilla-parser-jvm-plugin-backbone:jar:24.4.1:compile [INFO] | | | | +- com.vaadin:hilla-parser-jvm-plugin-nonnull:jar:24.4.1:compile [INFO] | | | | +- com.vaadin:hilla-parser-jvm-plugin-subtypes:jar:24.4.1:compile [INFO] | | | | +- com.vaadin:hilla-parser-jvm-plugin-model:jar:24.4.1:compile [INFO] | | | | - com.vaadin:hilla-parser-jvm-plugin-transfertypes:jar:24.4.1:compile

khergalant commented 3 months ago

After removing hilla from classpath (https://vaadin.com/blog/streamlined-vaadin-flow-setup-for-v24.4), everyting is fine :

<dependency>
            <groupId>com.vaadin</groupId>
            <!-- Replace artifactId with vaadin-core to use only free components -->
            <artifactId>vaadin</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>com.vaadin</groupId>
                    <artifactId>copilot</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.vaadin</groupId>
                    <artifactId>hilla-dev</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.vaadin</groupId>
                    <artifactId>hilla</artifactId>
                </exclusion>
            </exclusions>
        </dependency>       
        <dependency>            
                <groupId>com.vaadin</groupId>           
                <artifactId>vaadin-spring-boot-starter</artifactId>             
                <exclusions>
                     <exclusion>
                         <groupId>com.vaadin</groupId>
                         <artifactId>hilla</artifactId>
                    </exclusion>
            </exclusions> 
        </dependency>
khergalant commented 3 months ago

I had this param : mvc.pathmatch.matching-strategy = ant-path-matcher I remove it and allready is fine. Sorry for the issue.