spring-cloud-function icon indicating copy to clipboard operation
spring-cloud-function copied to clipboard

[5.0.0] transitive dependencies make "FunctionEndpointInitializer" initialize on webmvc demo

Open SingKS8 opened this issue 2 months ago • 0 comments

Describe the bug Please provide details of the problem, including the version of Spring Cloud that you are using.

I have upgraded my demo, version updates is below spring boot 3.5.8 -> 4.0.0 (webmvc) spring-cloud-starter-function-web 4.3.0 -> 5.0.0 (cloud 2025.1.0)

Two dependencies of "spring-cloud-function-web", "spring-boot-webclient" and "spring-boot-webtestclient" are not optional, both of them have transitive dependency "spring-webflux".

Exception in thread "main" java.lang.IllegalArgumentException: Unable to instantiate factory class [org.springframework.cloud.function.web.function.FunctionEndpointInitializer] for factory type [org.springframework.context.ApplicationContextInitializer]
	at org.springframework.core.io.support.SpringFactoriesLoader$FailureHandler.lambda$throwing$0(SpringFactoriesLoader.java:632)
	at org.springframework.core.io.support.SpringFactoriesLoader$FailureHandler.lambda$handleMessage$0(SpringFactoriesLoader.java:656)
	at org.springframework.core.io.support.SpringFactoriesLoader.instantiateFactory(SpringFactoriesLoader.java:225)
	at org.springframework.core.io.support.SpringFactoriesLoader.load(SpringFactoriesLoader.java:201)
	at org.springframework.core.io.support.SpringFactoriesLoader.load(SpringFactoriesLoader.java:157)
	at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:481)
	at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:477)
	at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:281)
	at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:260)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1374)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1363)
	at xyz.opcal.demo.FunctionWebApplication.main(FunctionWebApplication.java:10)
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/webflux/error/ErrorAttributes
	at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3551)
	at java.base/java.lang.Class.getConstructors(Class.java:2229)
	at org.springframework.core.io.support.SpringFactoriesLoader$FactoryInstantiator.findConstructor(SpringFactoriesLoader.java:400)
	at org.springframework.core.io.support.SpringFactoriesLoader$FactoryInstantiator.forClass(SpringFactoriesLoader.java:390)
	at org.springframework.core.io.support.SpringFactoriesLoader.instantiateFactory(SpringFactoriesLoader.java:221)
	... 9 more
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.webflux.error.ErrorAttributes
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
	... 15 more

Sample If possible, please provide a test case or sample application that reproduces the problem. This makes it much easier for us to diagnose the problem and to verify that we have fixed it.

SingKS8 avatar Dec 01 '25 17:12 SingKS8