I'm encountering a persistent BeanCreationException
in my Spring Boot 3.2.2/Vaadin 24.6.6 application, and I've exhausted my troubleshooting options. The error message is: .springframework.beans.factory.BeanCreationException: Error creating bean with name 1 'VaadinSecurityFilterChainBean' defined in class path resource .../config/SecurityConfig.class]: No matching factory method found on class [... .config.SecurityConfig]: factory bean 'securityConfig'; factory method 'filterChain()'. Check that a method with the specified name exists and that it is non-static.
This error indicates that Spring is unable to find the filterChain()
method in my SecurityConfig
class.
Here's a breakdown of what I've tried:
- Verified
SecurityConfig.java
:- The
SecurityConfig.java
file is in the correct package (com.clarkemiddle.skitripvaadin.config
). - It has the
@EnableWebSecurity
and@Configuration
annotations. - It extends
VaadinWebSecurity
. - The
filterChain()
method has the correct signature:@Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception
. - The method is not static.
- The
- Compilation and Class Files:
- I've performed
mvn clean install
multiple times. - I've checked the
target/classes/com/clarkemiddle/skitripvaadin/config
directory, andSecurityConfig.class
is present. - I have used a decompiler to check the contents of the SecurityConfig.class file, and the filter chain method is present.
- I've performed
- Command-Line Execution:
- I've run the application from the command line using
mvn spring-boot:run
.
- I've run the application from the command line using
- Dependency Checks:
- I've used
mvn dependency:tree
to check for conflicting dependencies. - I have tried explicitly defining the vaadin-spring-security version in my pom.xml.
- I've used
- Minimal Configuration:
- I've tried a minimal
SecurityConfig
with justhttp.authorizeHttpRequests(auth -> auth.anyRequest().permitAll());
.
- I've tried a minimal
- New Project:
- I've created a new Spring Boot/Vaadin project and copied my
SecurityConfig.java
andLoginView.java
files, but the error persists.
- I've created a new Spring Boot/Vaadin project and copied my
- IDE Checks:
- I have invalidated my IDE's caches, and restarted the IDE.
- Java Version:
- I am using Java 17.
- I have checked that the application class is in the correct package, and has the @SpringBootApplication annotation.
Here is my SecurityConfig.java:
import com.clarkemiddle.skitripvaadin.view.LoginView;
import .springframework.context.annotation.Bean;
import .springframework.context.annotation.Configuration;
import .springframework.security.config.annotation.web.builders.HttpSecurity;
import .springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import .springframework.security.core.userdetails.User;
import .springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import .springframework.security.crypto.password.PasswordEncoder;
import .springframework.security.provisioning.InMemoryUserDetailsManager;
import .springframework.security.provisioning.UserDetailsManager;
import com.vaadin.flow.spring.security.VaadinWebSecurity;
import .springframework.security.web.SecurityFilterChain;
@EnableWebSecurity
@Configuration
public class SecurityConfig extends VaadinWebSecurity {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests(auth -> auth
.requestMatchers("/", "/register", "/login").permitAll()
.anyRequest().authenticated()
);
setLoginView(http, LoginView.class);
return http.build();
}
@Bean
UserDetailsManager userDetailsManager() {
// In a production application, replace InMemoryUserDetailsManager with a database-backed UserDetailsService
return new InMemoryUserDetailsManager(
User.withUsername("username")
.password(passwordEncoder().encode("123456"))
.roles("USER").build()
);
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
And my dependencies:
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.33</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>${vaadin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
I'm encountering a persistent BeanCreationException
in my Spring Boot 3.2.2/Vaadin 24.6.6 application, and I've exhausted my troubleshooting options. The error message is: .springframework.beans.factory.BeanCreationException: Error creating bean with name 1 'VaadinSecurityFilterChainBean' defined in class path resource .../config/SecurityConfig.class]: No matching factory method found on class [... .config.SecurityConfig]: factory bean 'securityConfig'; factory method 'filterChain()'. Check that a method with the specified name exists and that it is non-static.
This error indicates that Spring is unable to find the filterChain()
method in my SecurityConfig
class.
Here's a breakdown of what I've tried:
- Verified
SecurityConfig.java
:- The
SecurityConfig.java
file is in the correct package (com.clarkemiddle.skitripvaadin.config
). - It has the
@EnableWebSecurity
and@Configuration
annotations. - It extends
VaadinWebSecurity
. - The
filterChain()
method has the correct signature:@Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception
. - The method is not static.
- The
- Compilation and Class Files:
- I've performed
mvn clean install
multiple times. - I've checked the
target/classes/com/clarkemiddle/skitripvaadin/config
directory, andSecurityConfig.class
is present. - I have used a decompiler to check the contents of the SecurityConfig.class file, and the filter chain method is present.
- I've performed
- Command-Line Execution:
- I've run the application from the command line using
mvn spring-boot:run
.
- I've run the application from the command line using
- Dependency Checks:
- I've used
mvn dependency:tree
to check for conflicting dependencies. - I have tried explicitly defining the vaadin-spring-security version in my pom.xml.
- I've used
- Minimal Configuration:
- I've tried a minimal
SecurityConfig
with justhttp.authorizeHttpRequests(auth -> auth.anyRequest().permitAll());
.
- I've tried a minimal
- New Project:
- I've created a new Spring Boot/Vaadin project and copied my
SecurityConfig.java
andLoginView.java
files, but the error persists.
- I've created a new Spring Boot/Vaadin project and copied my
- IDE Checks:
- I have invalidated my IDE's caches, and restarted the IDE.
- Java Version:
- I am using Java 17.
- I have checked that the application class is in the correct package, and has the @SpringBootApplication annotation.
Here is my SecurityConfig.java:
import com.clarkemiddle.skitripvaadin.view.LoginView;
import .springframework.context.annotation.Bean;
import .springframework.context.annotation.Configuration;
import .springframework.security.config.annotation.web.builders.HttpSecurity;
import .springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import .springframework.security.core.userdetails.User;
import .springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import .springframework.security.crypto.password.PasswordEncoder;
import .springframework.security.provisioning.InMemoryUserDetailsManager;
import .springframework.security.provisioning.UserDetailsManager;
import com.vaadin.flow.spring.security.VaadinWebSecurity;
import .springframework.security.web.SecurityFilterChain;
@EnableWebSecurity
@Configuration
public class SecurityConfig extends VaadinWebSecurity {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests(auth -> auth
.requestMatchers("/", "/register", "/login").permitAll()
.anyRequest().authenticated()
);
setLoginView(http, LoginView.class);
return http.build();
}
@Bean
UserDetailsManager userDetailsManager() {
// In a production application, replace InMemoryUserDetailsManager with a database-backed UserDetailsService
return new InMemoryUserDetailsManager(
User.withUsername("username")
.password(passwordEncoder().encode("123456"))
.roles("USER").build()
);
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
And my dependencies:
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.33</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>${vaadin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Share
Improve this question
asked Mar 8 at 6:15
Aerialdad14Aerialdad14
11 silver badge
3
|
1 Answer
Reset to default 2Vaadin 24.6.6 does not work with Spring Boot 3.2, you need to use at least Spring Boot 3.4.
https://github/vaadin/platform/releases/tag/24.6.0
vaadin.version
? – dan1st Commented Mar 8 at 6:40<properties> <vaadin.version>24.6.6</vaadin.version> </properties>
– Aerialdad14 Commented Mar 8 at 16:18This error indicates that Spring is unable to find the filterChain()
- that is not what the error indicates.Error creating bean with name 1 'VaadinSecurityFilterChainBean'
line says that it can't find the bean calledVaadinSecurityFilterChainBean
. I am guessing that bean is sth you are trying to autowire somewhere (perhaps even as method parameter infilterChain()
method or somewhere in that class? – asgarov1 Commented Mar 8 at 17:00