Problem generate in spring boot Version: 3.4.0. It's normal in spring boot 3.3.6.
error log:
> Task :micro-blog:processAot
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.4.0)
2024-11-22T08:58:56.607+08:00 INFO 55656 --- [ main] w.chiu.micro.blog.MicroBlogApplication : Starting MicroBlogApplication using Java 23.0.1 with PID 55656 (/Users/mingchiuli/Desktop/megalith-micro/micro-blog/build/classes/java/main started by mingchiuli in /Users/mingchiuli/Desktop/megalith-micro/micro-blog)
2024-11-22T08:58:56.609+08:00 INFO 55656 --- [ main] w.chiu.micro.blog.MicroBlogApplication : The following 1 profile is active: "dev"
2024-11-22T08:58:57.159+08:00 INFO 55656 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode
2024-11-22T08:58:57.159+08:00 INFO 55656 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2024-11-22T08:58:57.240+08:00 INFO 55656 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 76 ms. Found 2 JPA repository interfaces.
2024-11-22T08:58:57.250+08:00 INFO 55656 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode
2024-11-22T08:58:57.251+08:00 INFO 55656 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode.
2024-11-22T08:58:57.261+08:00 INFO 55656 --- [ main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface wiki.chiu.micro.blog.repository.BlogRepository; If you want this repository to be a Redis repository, consider annotating your entities with one of these annotations: org.springframework.data.redis.core.RedisHash (preferred), or consider extending one of the following types with your repository: org.springframework.data.keyvalue.repository.KeyValueRepository
2024-11-22T08:58:57.261+08:00 INFO 55656 --- [ main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface wiki.chiu.micro.blog.repository.BlogSensitiveContentRepository; If you want this repository to be a Redis repository, consider annotating your entities with one of these annotations: org.springframework.data.redis.core.RedisHash (preferred), or consider extending one of the following types with your repository: org.springframework.data.keyvalue.repository.KeyValueRepository
2024-11-22T08:58:57.261+08:00 INFO 55656 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 5 ms. Found 0 Redis repository interfaces.
Exception in thread "main" java.lang.StackOverflowError
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.checkReceiver(DirectMethodHandleAccessor.java:196)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:99)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:281)
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:265)
at org.springframework.core.SerializableTypeWrapper$MethodInvokeTypeProvider.getType(SerializableTypeWrapper.java:357)
at org.springframework.core.SerializableTypeWrapper.forTypeProvider(SerializableTypeWrapper.java:106)
at org.springframework.core.SerializableTypeWrapper$TypeProxyInvocationHandler.invoke(SerializableTypeWrapper.java:215)
at org.springframework.core.$Proxy6.getActualTypeArguments(Unknown Source)
at org.springframework.core.ResolvableType.getGenerics(ResolvableType.java:809)
at org.springframework.core.ResolvableType.getGeneric(ResolvableType.java:762)
at org.springframework.validation.beanvalidation.BeanValidationBeanRegistrationAotProcessor$BeanValidationDelegate.lambda$processAheadOfTime$0(BeanValidationBeanRegistrationAotProcessor.java:162)
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:728)
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:707)
at org.springframework.validation.beanvalidation.BeanValidationBeanRegistrationAotProcessor$BeanValidationDelegate.processAheadOfTime(BeanValidationBeanRegistrationAotProcessor.java:150)
at org.springframework.validation.beanvalidation.BeanValidationBeanRegistrationAotProcessor$BeanValidationDelegate.lambda$processAheadOfTime$0(BeanValidationBeanRegistrationAotProcessor.java:170)
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:728)
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:707)
at org.springframework.validation.beanvalidation.BeanValidationBeanRegistrationAotProcessor$BeanValidationDelegate.processAheadOfTime(BeanValidationBeanRegistrationAotProcessor.java:150)
at org.springframework.validation.beanvalidation.BeanValidationBeanRegistrationAotProcessor$BeanValidationDelegate.lambda$processAheadOfTime$0(BeanValidationBeanRegistrationAotProcessor.java:170)
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:728)
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:707)
at org.springframework.validation.beanvalidation.BeanValidationBeanRegistrationAotProcessor$BeanValidationDelegate.processAheadOfTime(BeanValidationBeanRegistrationAotProcessor.java:150)
at org.springframework.validation.beanvalidation.BeanValidationBeanRegistrationAotProcessor$BeanValidationDelegate.lambda$processAheadOfTime$0(BeanValidationBeanRegistrationAotProcessor.java:170)
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:728)
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:707)
at org.springframework.validation.beanvalidation.BeanValidationBeanRegistrationAotProcessor$BeanValidationDelegate.processAheadOfTime(BeanValidationBeanRegistrationAotProcessor.java:150)
at org.springframework.validation.beanvalidat
Comment From: bclozel
Can you provide a minimal sample application that reproduces the problem please?
Comment From: waileong
I'm encountering the same issue, which seems to be caused by 33842
Comment From: bclozel
@waileong can you provide a minimal sample application? This would help us speed us the resolution process.
Comment From: itineric
Having the same error.
The usecase to reproduce is not ideal, but cannot find a better one for now.
I have an empty spring Application
@SpringBootApplication
public class MyApplication
{
public static void main(final String[] args)
{
SpringApplication.run(MyApplication.class, args);
}
}
But these dependencies in my pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
I get the StackOverflowError during AOT. If I remove one or the other dependency, it works. I'm stuck here since it seems to have nothing to do with my apps.
Comment From: bsgrd
Having the same error.
The usecase to reproduce is not ideal, but cannot find a better one for now.
I have an empty spring Application
@SpringBootApplication public class MyApplication { public static void main(final String[] args) { SpringApplication.run(MyApplication.class, args); } }
But these dependencies in my pom.xml
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-amqp</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> </dependency>
I get the StackOverflowError during AOT. If I remove one or the other dependency, it works. I'm stuck here since it seems to have nothing to do with my apps.
I can confirm that removing "spring-boot-starter-validation" and "spring-cloud-stream-binder-kafka" "fixed" the issue for me.
Comment From: bsgrd
For me the issue was the combination of "spring-boot-starter-validation" and "org.springdoc:springdoc-openapi-starter-webmvc-api:2.6.0". I have created a minimum application here: https://github.com/bsgrd/spring-framework-issues-33936
Comment From: javapapo
+1 on the above aot + spring-starter-validation
Comment From: mingchiuli
For me the issue was the combination of "spring-boot-starter-validation" and "org.springdoc:springdoc-openapi-starter-webmvc-api:2.6.0". I have created a minimum application here: https://github.com/bsgrd/spring-framework-issues-33936
@bclozel This instance can show my problem
Comment From: waileong
@bclozel
Minimal sample application https://github.com/waileong/spring-aot-infinite-recursive
Cause of the StackOverflowError
The issue is caused by the commit 357dbc0, which introduced a recursive processAheadOfTime method without a condition to break the recursion. This leads to an infinite recursive loop and eventually a StackOverflowError.
Suggested Fix
To resolve the issue, add a condition to break the infinite recursive loop by keeping track of the classes that have already been validated.
if (validatedClasses.contains(clazz)) {
// Break the infinite recursive loop
logger.debug("Class {} has already been validated.", clazz.getName());
return;
}
Comment From: sbrannen
- superseded by #33950