Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gateway Server MVC support for AOT #3171

Closed
wisskirchenj opened this issue Dec 10, 2023 · 4 comments · Fixed by #3193
Closed

Gateway Server MVC support for AOT #3171

wisskirchenj opened this issue Dec 10, 2023 · 4 comments · Fixed by #3193
Milestone

Comments

@wisskirchenj
Copy link
Contributor

wisskirchenj commented Dec 10, 2023

EDIT:
Let me add, that this "bug" (or better use of an for AOT unsupported bean definition method) presently prevents ANY Spring Boot app using spring-cloud-gateway-server-mvc from being run as a native image - as any will need to instantiate the beans during AutoConfiguration...

Describe the bug
Spring Cloud Gateway 4.1.0 release (2023.0.0 train) based Spring Boot app - using new gateway-server-mvc - with minimal path-predicate routing to webservice apps, CRASHES in Gradle's processAot task on application startup with (shortened)
stack-trace as shown below. Running the app (JVM w/o AOT) works fine.
Same in integration testing ("solved" with @DisabledInAotMode)

_Exception in thread "main" java.lang.IllegalStateException: Default code generation is not supported for bean definitions declaring an instance supplier callback: Root bean: class [org.springframework.cloud.gateway.server.mvc.config.GatewayMvcPropertiesBeanDefinitionRegistrar$RouterFunctionHolder]; scope=refresh; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=false; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodNames=null; destroyMethodNames=null
	at org.springframework.beans.factory.aot.DefaultBeanRegistrationCodeFragments.getTarget(DefaultBeanRegistrationCodeFragments.java:78)
	at org.springframework.beans.factory.aot.BeanDefinitionMethodGenerator.generateBeanDefinitionMethod(BeanDefinitionMethodGenerator.java:85)
	at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution.lambda$generateRegisterBeanDefinitionsMethod$2(BeanRegistrationsAotContribution.java:90)_

Sample
Code for above mentioned app is publicly accessible at https://github.com/wisskirchenj/gateway/tree/spring-issue-ref, where I stripped off all non-essential features in this branch for reference.

@wisskirchenj
Copy link
Contributor Author

wisskirchenj commented Dec 11, 2023

I managed to workaround - so I can run my Gateway app as native image again - by

I can offer to improve on this solution (configure the requestScope toggle) and send a Pull Request - if there is interest.

@spencergibb
Copy link
Member

A PR would be most welcome!

/cc @joshlong

@joshlong
Copy link

I love this !

@spencergibb spencergibb changed the title The latest "GatewayMvcPropertiesBeanDefinitionRegistrar" class is not AOT ready Gateway Server MVC support for AOT Dec 20, 2023
@wisskirchenj
Copy link
Contributor Author

wisskirchenj commented Dec 23, 2023

@spencergibb @joshlong
Just added my announced PR #3193.
I am happy to elaborate on your review comments and also add test(s) if you need. Just instruct me :-)

@spencergibb spencergibb added this to the 4.1.2 milestone Mar 8, 2024
@spencergibb spencergibb moved this to In Progress in 2023.0.1 Mar 18, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in 2023.0.1 Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants