'Upgrading spring boot to 2.5.12
I am upgrading spring boot version to 2.5.12 from 2.3.10.RELEASE because of the vulnerability issues. But I am getting below error while starting the application
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
[2022-04-08 16:32:15.146] - 34399 SEVERE [main] --- org.springframework.boot.SpringApplication: Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configurationPropertiesBeans' defined in org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.context.properties.ConfigurationPropertiesBeans]: Factory method 'configurationPropertiesBeans' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658)
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
at org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration.configurationPropertiesBeans(ConfigurationPropertiesRebinderAutoConfiguration.java:51)
at org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$ac3fd244.CGLIB$configurationPropertiesBeans$2(<generated>)
at org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$ac3fd244$$FastClassBySpringCGLIB$$403b91a4.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
at org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$ac3fd244.configurationPropertiesBeans(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
... 35 more
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.properties.ConfigurationBeanFactoryMetadata
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 46 more
I dont have spring-cloud-dependencies in my pom, as I saw it here BeanCreationException: Error creating bean with name 'configurationPropertiesBeans' defined in class path resource please suggest how to resolve this.
Solution 1:[1]
You need to update your spring cloud version to 2020.0.5. make sure you have updated other dependencies properly.
Solution 2:[2]
I also a faced a similar issue, then i have updated to the spring boot 2.5.13 version. There were some important bugs were fixed in the 2.5.13 version. Please refer this release note[1].
[1] https://github.com/spring-projects/spring-boot/releases/tag/v2.5.13
Solution 3:[3]
I also a faced a similar issue after update to "spring boot" 2.5.12.
Then i have updated "spring boot" version to 2.5.13 version and "spring cloud" version to 2020.0.5. But this not helped.
Finally I found that my issue is connected to Sleuth library (org.springframework.cloud:spring-cloud-starter-sleuth) we are using in our project.
Sleuth has unresolved bug, which causes problem if you use async code in your application (@EnableAsync, AsyncConfigurer).
Here the workaround you could use to resolve the issue:
https://github.com/spring-cloud/spring-cloud-sleuth/issues/2100#issuecomment-1036248102
P.S. My error was:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'apixxxRoutine' defined in file
[/Users/arybachenko/javadev/xxx/xxx_src/xxx-marketapp/build/classes/java/main/com/xxx/xxxpackage/market/schedule/routine/Routine.class]:
Unsatisfied dependency expressed through constructor parameter 7;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'cachedThreadPool' defined in class path resource
[com/xxx/xxxpackage/libs/routine/configuration/RoutineAsyncConfiguration.class]:
Bean instantiation via factory method failed;
nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [java.util.concurrent.ExecutorService]:
Illegal arguments to factory method 'cachedThreadPool'; args: ;
nested exception is java.lang.IllegalArgumentException:
object is not an instance of declaring class
Solution 4:[4]
You need to add this dependency
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>2020.0.5</version>
<type>pom</type>
<scope>import</scope>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Satya Prakash |
Solution 2 | Senthuran |
Solution 3 | Rib47 |
Solution 4 | yahitesh |