spring-statemachine icon indicating copy to clipboard operation
spring-statemachine copied to clipboard

StateMachineConfigBuilder not compatible with Spring Boot 3.0 Native image AOT processing

Open TheMorganHub opened this issue 2 years ago • 20 comments

Spring Boot 3.0 brings support for native image creation.

I've recently upgraded my project, which implements spring-statemachine-core 3.2.0, to Spring Boot 3.0 and was eager to try out the new native image creation. However, when I run mvn spring-boot:process-aot, I get the following error:

Exception in thread "main" java.lang.IllegalArgumentException: Failed to generate code for 'org.springframework.statemachine.config.builders.StateMachineConfigBuilder@6b3b4f37' with type org.springframework.statemachine.config.builders.StateMachineConfigBuilder<?, ?>
        at org.springframework.beans.factory.aot.BeanDefinitionPropertyValueCodeGenerator.generateCode(BeanDefinitionPropertyValueCodeGenerator.java:101)
        at org.springframework.beans.factory.aot.BeanDefinitionPropertiesCodeGenerator.generateValue(BeanDefinitionPropertiesCodeGenerator.java:186)
        at org.springframework.beans.factory.aot.BeanDefinitionPropertiesCodeGenerator.lambda$addConstructorArgumentValues$3(BeanDefinitionPropertiesCodeGenerator.java:151)
        at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721)
        at java.base/java.util.Collections$UnmodifiableMap.forEach(Collections.java:1553)
        at org.springframework.beans.factory.aot.BeanDefinitionPropertiesCodeGenerator.addConstructorArgumentValues(BeanDefinitionPropertiesCodeGenerator.java:150)
        at org.springframework.beans.factory.aot.BeanDefinitionPropertiesCodeGenerator.generateCode(BeanDefinitionPropertiesCodeGenerator.java:119)
        at org.springframework.beans.factory.aot.DefaultBeanRegistrationCodeFragments.generateSetBeanDefinitionPropertiesCode(DefaultBeanRegistrationCodeFragments.java:146)
        at org.springframework.beans.factory.aot.BeanRegistrationCodeGenerator.generateCode(BeanRegistrationCodeGenerator.java:86)
        at org.springframework.beans.factory.aot.BeanDefinitionMethodGenerator.lambda$generateBeanDefinitionMethod$3(BeanDefinitionMethodGenerator.java:186)
        at org.springframework.aot.generate.GeneratedMethod.<init>(GeneratedMethod.java:54)
        at org.springframework.aot.generate.GeneratedMethods.add(GeneratedMethods.java:112)
        at org.springframework.aot.generate.GeneratedMethods.add(GeneratedMethods.java:89)
        at org.springframework.beans.factory.aot.BeanDefinitionMethodGenerator.generateBeanDefinitionMethod(BeanDefinitionMethodGenerator.java:180)
        at org.springframework.beans.factory.aot.BeanDefinitionMethodGenerator.generateBeanDefinitionMethod(BeanDefinitionMethodGenerator.java:102)
        at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution.lambda$generateRegisterBeanDefinitionsMethod$2(BeanRegistrationsAotContribution.java:85)
        at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721)
        at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution.generateRegisterBeanDefinitionsMethod(BeanRegistrationsAotContribution.java:83)
        at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution.lambda$applyTo$1(BeanRegistrationsAotContribution.java:67)
        at org.springframework.aot.generate.GeneratedMethod.<init>(GeneratedMethod.java:54)
        at org.springframework.aot.generate.GeneratedMethods.add(GeneratedMethods.java:112)
        at org.springframework.aot.generate.GeneratedMethods.add(GeneratedMethods.java:89)
        at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution.applyTo(BeanRegistrationsAotContribution.java:66)
        at org.springframework.context.aot.BeanFactoryInitializationAotContributions.applyTo(BeanFactoryInitializationAotContributions.java:78)
        at org.springframework.context.aot.ApplicationContextAotGenerator.lambda$processAheadOfTime$0(ApplicationContextAotGenerator.java:58)
        at org.springframework.context.aot.ApplicationContextAotGenerator.withCglibClassHandler(ApplicationContextAotGenerator.java:67)
        at org.springframework.context.aot.ApplicationContextAotGenerator.processAheadOfTime(ApplicationContextAotGenerator.java:53)
        at org.springframework.context.aot.ContextAotProcessor.performAotProcessing(ContextAotProcessor.java:106)
        at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:84)
        at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:49)
        at org.springframework.context.aot.AbstractAotProcessor.process(AbstractAotProcessor.java:82)
        at org.springframework.boot.SpringApplicationAotProcessor.main(SpringApplicationAotProcessor.java:76)
Caused by: java.lang.IllegalArgumentException: Code generation does not support org.springframework.statemachine.config.builders.StateMachineConfigBuilder<?, ?>
        at org.springframework.beans.factory.aot.BeanDefinitionPropertyValueCodeGenerator.generateCode(BeanDefinitionPropertyValueCodeGenerator.java:133)
        at org.springframework.beans.factory.aot.BeanDefinitionPropertyValueCodeGenerator.generateCode(BeanDefinitionPropertyValueCodeGenerator.java:98)
        ... 31 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.052 s
[INFO] Finished at: 2022-12-12T20:41:00-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.0:process-aot (default-cli) on project glamitoms: Process terminated with exit code: 1 -> [Help 1]

I've tried downgrading and switching versions of Spring SM but I get the same error every time. Are projects that use Spring SM not intended to be used along with GraalVM native?

TheMorganHub avatar Dec 12 '22 23:12 TheMorganHub

There is a pull request for upgrading to 3 (https://github.com/spring-projects/spring-statemachine/pull/1104).

egreijus avatar Jun 27 '23 10:06 egreijus

That pull request is closed, but as of today, 20 December 2023, this error is still happening with Spring AOT processing.

Steve973 avatar Dec 20 '23 19:12 Steve973

This is Spring boot 3.2.0 and statemachine 4.0.0, by the way.

Steve973 avatar Dec 20 '23 19:12 Steve973

I see this error in Spring boot 3.2.2 as well.

Exception in thread "main" org.springframework.aot.generate.ValueCodeGenerationException: Failed to generate code for 'org.springframework.statemachine.config.builders.StateMachineConfigBuilder@5967f0ff' with type class org.springframework.statemachine.config.builders.StateMachineConfigBuilder
	at org.springframework.aot.generate.ValueCodeGenerator.generateCode(ValueCodeGenerator.java:116)
	at org.springframework.beans.factory.aot.BeanDefinitionPropertiesCodeGenerator.generateValue(BeanDefinitionPropertiesCodeGenerator.java:269)
	at org.springframework.beans.factory.aot.BeanDefinitionPropertiesCodeGenerator.lambda$addConstructorArgumentValues$3(BeanDefinitionPropertiesCodeGenerator.java:191)
	at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721)
	at java.base/java.util.Collections$UnmodifiableMap.forEach(Collections.java:1553)
	at org.springframework.beans.factory.aot.BeanDefinitionPropertiesCodeGenerator.addConstructorArgumentValues(BeanDefinitionPropertiesCodeGenerator.java:188)
	at org.springframework.beans.factory.aot.BeanDefinitionPropertiesCodeGenerator.generateCode(BeanDefinitionPropertiesCodeGenerator.java:134)
	at org.springframework.beans.factory.aot.DefaultBeanRegistrationCodeFragments.generateSetBeanDefinitionPropertiesCode(DefaultBeanRegistrationCodeFragments.java:181)
	at org.springframework.beans.factory.aot.BeanRegistrationCodeGenerator.generateCode(BeanRegistrationCodeGenerator.java:81)
	at org.springframework.beans.factory.aot.BeanDefinitionMethodGenerator.lambda$generateBeanDefinitionMethod$3(BeanDefinitionMethodGenerator.java:176)
	at org.springframework.aot.generate.GeneratedMethod.<init>(GeneratedMethod.java:54)
	at org.springframework.aot.generate.GeneratedMethods.add(GeneratedMethods.java:112)
	at org.springframework.aot.generate.GeneratedMethods.add(GeneratedMethods.java:89)
	at org.springframework.beans.factory.aot.BeanDefinitionMethodGenerator.generateBeanDefinitionMethod(BeanDefinitionMethodGenerator.java:169)
	at org.springframework.beans.factory.aot.BeanDefinitionMethodGenerator.generateBeanDefinitionMethod(BeanDefinitionMethodGenerator.java:89)
	at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution.lambda$generateRegisterBeanDefinitionsMethod$2(BeanRegistrationsAotContribution.java:90)
	at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721)
	at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution.generateRegisterBeanDefinitionsMethod(BeanRegistrationsAotContribution.java:88)
	at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution.lambda$applyTo$1(BeanRegistrationsAotContribution.java:73)
	at org.springframework.aot.generate.GeneratedMethod.<init>(GeneratedMethod.java:54)
	at org.springframework.aot.generate.GeneratedMethods.add(GeneratedMethods.java:112)
	at org.springframework.aot.generate.GeneratedMethods.add(GeneratedMethods.java:89)
	at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution.applyTo(BeanRegistrationsAotContribution.java:72)
	at org.springframework.context.aot.BeanFactoryInitializationAotContributions.applyTo(BeanFactoryInitializationAotContributions.java:78)
	at org.springframework.context.aot.ApplicationContextAotGenerator.lambda$processAheadOfTime$0(ApplicationContextAotGenerator.java:58)
	at org.springframework.context.aot.ApplicationContextAotGenerator.withCglibClassHandler(ApplicationContextAotGenerator.java:67)
	at org.springframework.context.aot.ApplicationContextAotGenerator.processAheadOfTime(ApplicationContextAotGenerator.java:53)
	at org.springframework.context.aot.ContextAotProcessor.performAotProcessing(ContextAotProcessor.java:106)
	at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:84)
	at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:49)
	at org.springframework.context.aot.AbstractAotProcessor.process(AbstractAotProcessor.java:82)
	at org.springframework.boot.SpringApplicationAotProcessor.main(SpringApplicationAotProcessor.java:80)
Caused by: org.springframework.aot.generate.UnsupportedTypeValueCodeGenerationException: Code generation does not support org.springframework.statemachine.config.builders.StateMachineConfigBuilder
	at org.springframework.aot.generate.ValueCodeGenerator.generateCode(ValueCodeGenerator.java:113)

arun0009 avatar Mar 03 '24 01:03 arun0009

SpringBoot3.2.5 still

. ____ _ __ _ _ /\ / ' __ _ () __ __ _ \ \ \
( ( )_
_ | '_ | '| | ' / ` | \ \ \
\/ )| |)| | | | | || (| | ) ) ) ) ' |
| .__|| ||| |_, | / / / / =========||==============|/=//// :: Spring Boot :: (v3.2.5)

2024-05-16T10:49:17.134+08:00 INFO 12340 --- [ main] c.w.ln.WorldtechLnApplicationTests : Starting WorldtechLnApplicationTests using Java 17.0.11 with PID 12340 (started by 18721 in D:\Project\idea\worldtech-ln) 2024-05-16T10:49:17.135+08:00 INFO 12340 --- [ main] c.w.ln.WorldtechLnApplicationTests : No active profile set, falling back to 1 default profile: "default" 2024-05-16T10:49:17.610+08:00 INFO 12340 --- [ main] faultConfiguringBeanFactoryPostProcessor : No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created. 2024-05-16T10:49:17.615+08:00 INFO 12340 --- [ main] faultConfiguringBeanFactoryPostProcessor : No bean named 'integrationHeaderChannelRegistry' has been explicitly defined. Therefore, a default DefaultHeaderChannelRegistry will be created. 2024-05-16T10:49:18.442+08:00 INFO 12340 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 1 endpoint(s) beneath base path '/actuator' 2024-05-16T10:49:18.619+08:00 INFO 12340 --- [ main] o.s.i.endpoint.EventDrivenConsumer : Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel 2024-05-16T10:49:18.620+08:00 INFO 12340 --- [ main] o.s.i.channel.PublishSubscribeChannel : Channel 'application.errorChannel' has 1 subscriber(s). 2024-05-16T10:49:18.620+08:00 INFO 12340 --- [ main] o.s.i.endpoint.EventDrivenConsumer : started bean '_org.springframework.integration.errorLogger' 2024-05-16T10:49:18.630+08:00 INFO 12340 --- [ main] c.w.ln.WorldtechLnApplicationTests : Started WorldtechLnApplicationTests in 1.634 seconds (process running for 2.18) Java HotSpot(TM) 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.357 s -- in com.worldtech.ln.WorldtechLnApplicationTests [INFO] [INFO] Results: [INFO] [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] [INFO] --- spring-boot:3.2.5:process-aot (process-aot) @ worldtech-ln --- 10:49:19.539 [main] INFO org.springframework.boot.devtools.restart.RestartApplicationListener -- Restart disabled due to context in which it is running

. ____ _ __ _ _ /\ / ' __ _ () __ __ _ \ \ \
( ( )_
_ | '_ | '| | ' / ` | \ \ \
\/ )| |)| | | | | || (| | ) ) ) ) ' |
| .__|| ||| |_, | / / / / =========||==============|/=//// :: Spring Boot :: (v3.2.5)

2024-05-16T10:49:19.747+08:00 INFO 9320 --- [ main] c.worldtech.ln.WorldtechLnApplication : Starting WorldtechLnApplication using Java 17.0.11 with PID 9320 (D:\Project\idea\worldtech-ln\target\classes started by 18721 in D:\Project\idea\worldtech-ln) 2024-05-16T10:49:19.748+08:00 INFO 9320 --- [ main] c.worldtech.ln.WorldtechLnApplication : No active profile set, falling back to 1 default profile: "default" 2024-05-16T10:49:20.233+08:00 INFO 9320 --- [ main] faultConfiguringBeanFactoryPostProcessor : No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created. 2024-05-16T10:49:20.238+08:00 INFO 9320 --- [ main] faultConfiguringBeanFactoryPostProcessor : No bean named 'integrationHeaderChannelRegistry' has been explicitly defined. Therefore, a default DefaultHeaderChannelRegistry will be created. Exception in thread "main" org.springframework.aot.generate.ValueCodeGenerationException: Failed to generate code for 'org.springframework.web.util.pattern.PathPatternParser@647b9364' with type class org.springframework.web.util.pattern.PathPatternParser at org.springframework.aot.generate.ValueCodeGenerator.generateCode(ValueCodeGenerator.java:116) at org.springframework.beans.factory.aot.BeanDefinitionPropertiesCodeGenerator.generateValue(BeanDefinitionPropertiesCodeGenerator.java:269) at org.springframework.beans.factory.aot.BeanDefinitionPropertiesCodeGenerator.addPropertyValues(BeanDefinitionPropertiesCodeGenerator.java:228) at org.springframework.beans.factory.aot.BeanDefinitionPropertiesCodeGenerator.generateCode(BeanDefinitionPropertiesCodeGenerator.java:135) at org.springframework.beans.factory.aot.DefaultBeanRegistrationCodeFragments.generateSetBeanDefinitionPropertiesCode(DefaultBeanRegistrationCodeFragments.java:181) at org.springframework.beans.factory.aot.BeanRegistrationCodeGenerator.generateCode(BeanRegistrationCodeGenerator.java:81) at org.springframework.beans.factory.aot.BeanDefinitionMethodGenerator.lambda$generateBeanDefinitionMethod$3(BeanDefinitionMethodGenerator.java:176) at org.springframework.aot.generate.GeneratedMethod.(GeneratedMethod.java:54) at org.springframework.aot.generate.GeneratedMethods.add(GeneratedMethods.java:112) at org.springframework.aot.generate.GeneratedMethods.add(GeneratedMethods.java:89) at org.springframework.beans.factory.aot.BeanDefinitionMethodGenerator.generateBeanDefinitionMethod(BeanDefinitionMethodGenerator.java:169) at org.springframework.beans.factory.aot.BeanDefinitionMethodGenerator.generateBeanDefinitionMethod(BeanDefinitionMethodGenerator.java:89) at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution.lambda$generateRegisterBeanDefinitionsMethod$2(BeanRegistrationsAotContribution.java:90) at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721) at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution.generateRegisterBeanDefinitionsMethod(BeanRegistrationsAotContribution.java:88) at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution.lambda$applyTo$1(BeanRegistrationsAotContribution.java:73) at org.springframework.aot.generate.GeneratedMethod.(GeneratedMethod.java:54) at org.springframework.aot.generate.GeneratedMethods.add(GeneratedMethods.java:112) at org.springframework.aot.generate.GeneratedMethods.add(GeneratedMethods.java:89) at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution.applyTo(BeanRegistrationsAotContribution.java:72) at org.springframework.context.aot.BeanFactoryInitializationAotContributions.applyTo(BeanFactoryInitializationAotContributions.java:78) at org.springframework.context.aot.ApplicationContextAotGenerator.lambda$processAheadOfTime$0(ApplicationContextAotGenerator.java:58) at org.springframework.context.aot.ApplicationContextAotGenerator.withCglibClassHandler(ApplicationContextAotGenerator.java:67) at org.springframework.context.aot.ApplicationContextAotGenerator.processAheadOfTime(ApplicationContextAotGenerator.java:53) at org.springframework.context.aot.ContextAotProcessor.performAotProcessing(ContextAotProcessor.java:106) at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:84) at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:49) at org.springframework.context.aot.AbstractAotProcessor.process(AbstractAotProcessor.java:82) at org.springframework.boot.SpringApplicationAotProcessor.main(SpringApplicationAotProcessor.java:80) Caused by: org.springframework.aot.generate.UnsupportedTypeValueCodeGenerationException: Code generation does not support org.springframework.web.util.pattern.PathPatternParser at org.springframework.aot.generate.ValueCodeGenerator.generateCode(ValueCodeGenerator.java:113) ... 28 more

Marblog avatar May 16 '24 02:05 Marblog

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

libinbin880521 avatar May 16 '24 02:05 libinbin880521