spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
56.72k stars 38.15k forks source link

processAot cause StackOverflowError #33936

Open mingchiuli opened 16 hours ago

mingchiuli commented 16 hours ago

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
bclozel commented 11 hours ago

Can you provide a minimal sample application that reproduces the problem please?

waileong commented 9 hours ago

I'm encountering the same issue, which seems to be caused by 33842

bclozel commented 9 hours ago

@waileong can you provide a minimal sample application? This would help us speed us the resolution process.

itineric commented 8 hours ago

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.

bsgrd commented 7 hours ago

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.

bsgrd commented 6 hours ago

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

javapapo commented 2 hours ago

+1 on the above aot + spring-starter-validation

mingchiuli commented 1 hour ago

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