Affects: 5.3 and later
See https://github.com/spring-projects/spring-boot/issues/37153 for some background. In this case parsing has failed because a configuration class extends a class that doesn't exist. While the offending class can probably be identified using a debugger, it would be helpful if more information was included in the log message. In this case, the fully qualified name of the configuration class whose super-class is being processed would pinpoint the problem.
Comment From: snicoll
Looking at the related issue, the root exception message seems to be:
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class
However, I don't see how this would be possible as the error message has additional brackets with the bean class name for a very long time. https://github.com/spring-projects/spring-framework/blob/84045374744aee245d1ed717454cb91e5d1c1ad3/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java#L177-L178
I wonder if the OP in the boot issue hasn't tempered the exception message.
Comment From: snicoll
I have reproduced the problem and I can confirm that there is a class name. However, it is not the right class name:
```2023-10-24 17:27:59.938 ERROR 76689 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.example.demo23upgrade.Demo23UpgradeApplication]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfigurerAdapter.class] cannot be opened because it does not exist
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:188) ~[spring-context-5.3.30.jar!/:5.3.30]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:331) ~[spring-context-5.3.30.jar!/:5.3.30]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:247) ~[spring-context-5.3.30.jar!/:5.3.30]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:311) ~[spring-context-5.3.30.jar!/:5.3.30]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:112) ~[spring-context-5.3.30.jar!/:5.3.30]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:748) ~[spring-context-5.3.30.jar!/:5.3.30]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:564) ~[spring-context-5.3.30.jar!/:5.3.30]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.17.jar!/:2.7.17]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) ~[spring-boot-2.7.17.jar!/:2.7.17]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:409) ~[spring-boot-2.7.17.jar!/:2.7.17]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.17.jar!/:2.7.17]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300) ~[spring-boot-2.7.17.jar!/:2.7.17]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1289) ~[spring-boot-2.7.17.jar!/:2.7.17]
at com.example.demo23upgrade.Demo23UpgradeApplication.main(Demo23UpgradeApplication.java:10) ~[classes!/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[demo-23-upgrade-0.0.1-SNAPSHOT.jar:na]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:108) ~[demo-23-upgrade-0.0.1-SNAPSHOT.jar:na]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[demo-23-upgrade-0.0.1-SNAPSHOT.jar:na]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65) ~[demo-23-upgrade-0.0.1-SNAPSHOT.jar:na]
Caused by: java.io.FileNotFoundException: class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfigurerAdapter.class] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:203) ~[spring-core-5.3.30.jar!/:5.3.30]
at org.springframework.core.type.classreading.SimpleMetadataReader.getClassReader(SimpleMetadataReader.java:55) ~[spring-core-5.3.30.jar!/:5.3.30]
at org.springframework.core.type.classreading.SimpleMetadataReader.
It should be `TestConfiguration` that is defined as follows:
```java
@Configuration
public class TestConfiguration extends WebSecurityConfigurerAdapter { }
Comment From: snicoll
The revised exception message now looks as follows:
org.springframework.beans.factory.BeanDefinitionStoreException: I/O failure while processing configuration class [com.example.demo23upgrade.TestConfiguration]
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:250) ~[spring-context-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:188) ~[spring-context-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:304) ~[spring-context-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245) ~[spring-context-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:196) ~[spring-context-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:164) ~[spring-context-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:415) ~[spring-context-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:288) ~[spring-context-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:349) ~[spring-context-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:118) ~[spring-context-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:775) ~[spring-context-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:597) ~[spring-context-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:748) ~[spring-boot-3.2.0-SNAPSHOT.jar:3.2.0-SNAPSHOT]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:450) ~[spring-boot-3.2.0-SNAPSHOT.jar:3.2.0-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:322) ~[spring-boot-3.2.0-SNAPSHOT.jar:3.2.0-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1336) ~[spring-boot-3.2.0-SNAPSHOT.jar:3.2.0-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1325) ~[spring-boot-3.2.0-SNAPSHOT.jar:3.2.0-SNAPSHOT]
at com.example.demo23upgrade.Demo23UpgradeApplication.main(Demo23UpgradeApplication.java:10) ~[main/:na]
Caused by: java.io.FileNotFoundException: class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfigurerAdapter.class] cannot be opened because it does not exist
at org.springframework.core.type.classreading.SimpleMetadataReader.getClassReader(SimpleMetadataReader.java:54) ~[spring-core-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:48) ~[spring-core-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103) ~[spring-core-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
at org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory.createMetadataReader(ConcurrentReferenceCachingMetadataReaderFactory.java:86) ~[spring-boot-3.2.0-SNAPSHOT.jar:3.2.0-SNAPSHOT]
at org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory.getMetadataReader(ConcurrentReferenceCachingMetadataReaderFactory.java:73) ~[spring-boot-3.2.0-SNAPSHOT.jar:3.2.0-SNAPSHOT]
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:81) ~[spring-core-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassParser.asSourceClass(ConfigurationClassParser.java:620) ~[spring-context-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassParser$SourceClass.getSuperClass(ConfigurationClassParser.java:933) ~[spring-context-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:341) ~[spring-context-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245) ~[spring-context-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
... 17 common frames omitted
Comment From: sedhha
What's the solution to this? I have upgraded to spring 3+ and seeing this error where one of my Filters used to extend WebSecurityConfigurerAdapter
Comment From: snicoll
@sedhha please don't ask support on the issue tracker, especially on closed issues. "This" is about providing more context about a particular setup that is wrong. Reading the history of the issue you could see that WebSecurityConfigurerAdapter
no longer exists so please refer to Spring Security relelease notes.
Comment From: KalyaniPharkandekar
I am having the same error. Can you please explain how you resolved it ?