0

I'm attempting to upgrade a Vaadin Spring application from 23 to 24. All the hoops went fine, like renaming packages to jakarta, but I can't seem to figure this one out. The interwebs are not useful (VaadinSecurityFilterChainBean is not even found by google).

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'VaadinSecurityFilterChainBean' defined in class path resource [nl/softworks/selfroster/WebSecurityConfig.class]: No matching factory method found on class [nl.softworks.selfroster.WebSecurityConfig]: factory bean 'webSecurityConfig'; factory method 'filterChain()'. Check that a method with the specified name exists and that it is non-static.
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:620)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1324)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1161)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:561)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:961)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:915)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
    at org.springframework.boot.test.context.SpringBootContextLoader.lambda$loadContext$3(SpringBootContextLoader.java:137)
    at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:59)
    at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:47)
    at org.springframework.boot.SpringApplication.withHook(SpringApplication.java:1386)
    at org.springframework.boot.test.context.SpringBootContextLoader$ContextLoaderHook.run(SpringBootContextLoader.java:543)
    at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:137)
    at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:108)
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:183)
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117)
    ... 73 common frames omitted

How to fix this?

tbeernot
  • 2,473
  • 4
  • 24
  • 31
  • `VaadinSecurityFilterChainBean` is a class defined by you. Note, there are some API differences between Spring Boot 2.7 and 3.0 in Spring Security, `WebSecurityConfigurerAdapter` has been removed. – Tatu Lund Mar 13 '23 at 06:17
  • I understand. But I use the SecurityContext as suggested in the 24 upgrade (https://vaadin.com/docs/latest/upgrading), I still get this exception. – tbeernot Mar 13 '23 at 07:12
  • I've solved it by, unlike the upgrade example, include a method like this: @Bean(name = "VaadinSecurityFilterChainBean") public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {...} – tbeernot Mar 13 '23 at 07:32
  • Looks like small change in Spring Security. Can you formulate that as answer to this question so that this question is not left hanging unanswered. – Tatu Lund Mar 13 '23 at 10:17

1 Answers1

0

Solved it myself; in the end I had to create a method that differed from the one in the Vaadin 23 to 24 migration example, containing:

@Bean(name = "VaadinSecurityFilterChainBean") 
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
    ...
}
tbeernot
  • 2,473
  • 4
  • 24
  • 31