You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 23, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 23, 2023. It is now read-only.
Spring Cloud Function not working with Tomcat #368
The sample is Netty so I guess we just never tested this yet. The error at runtime is:
Exception in thread "main" java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.ApplicationContextInitializer : org.springframework.cloud.function.web.function.FunctionEndpointInitializer
at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:467)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:449)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:442)
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:284)
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:264)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1309)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1298)
at org.knative.examples.cloudevents.spring.CloudEventSampleApplication.main(CloudEventSampleApplication.java:26)
Caused by: java.lang.NoSuchMethodException: org.springframework.cloud.function.web.function.FunctionEndpointInitializer.<init>()
at java.lang.Class.getConstructor0(DynamicHub.java:3082)
at java.lang.Class.getDeclaredConstructor(DynamicHub.java:2178)
at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:462)
... 7 more
I tried fixing this by making the conditional class present check in FunctionEndpointInitializer static, and adding it to --initialize-at-build-time. Didn't work.
With verbose logs during the build I see in the logs:
WARNING: Could not register reflection metadata for org.springframework.cloud.function.web.function.FunctionEndpointInitializer. Reason: java.lang.NoClassDefFoundError: org/springframework/web/reactive/function/server/RouterFunction
@aclement Is there some fine tuning needed on the feature side?
I think the error is on Spring Cloud Function side, the classpath check is done on org.springframework.http.server.reactive.HttpHandler which is in spring-web so present when Spring MVC is used. The check should probably done using org.springframework.web.reactive.function.server.RouterFunction if the intent is to make it work only when spring-webflux is in the classpath.
@dsyer Could you please remind me how to reproduce the issue? Since we now have the build-time infrastructure we should be able to give it another try.
Activity
dsyer commentedon Nov 19, 2020
I tried fixing this by making the conditional class present check in
FunctionEndpointInitializerstatic, and adding it to--initialize-at-build-time. Didn't work.sdeleuze commentedon Nov 19, 2020
With verbose logs during the build I see in the logs:
@aclement Is there some fine tuning needed on the feature side?
aclement commentedon Nov 19, 2020
Just to clarify that message (
WARNING: Could not register reflection) is not from us, it is from GraalVM, but I will take a look.sdeleuze commentedon Nov 19, 2020
I think the error is on Spring Cloud Function side, the classpath check is done on
org.springframework.http.server.reactive.HttpHandlerwhich is inspring-webso present when Spring MVC is used. The check should probably done usingorg.springframework.web.reactive.function.server.RouterFunctionif the intent is to make it work only whenspring-webfluxis in the classpath.dsyer commentedon Nov 20, 2020
Still not working. Re-opening.
sdeleuze commentedon Nov 21, 2020
As analyzed by @aclement, the root issue is the
RouterFunctionlambda not it the classpath that makes the reflection entry not taken in account.We should probably wait 0.9.0 and #345 to fix it.
sdeleuze commentedon Feb 8, 2021
@dsyer Could you please remind me how to reproduce the issue? Since we now have the build-time infrastructure we should be able to give it another try.
dsyer commentedon Feb 8, 2021
Just switch the sample from webflux to web MVC. That should do it.
sdeleuze commentedon Feb 9, 2021
It seems this issue is now gone with GraalVM 21.0.0 and our new build-time infrastructure.