Skip to content

Gateway Server MVC support for AOT #3171

@wisskirchenj

Description

@wisskirchenj

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions