0

I'm changing my application to the new spring boot 3.0.5 with native graal.

When executing the processAot task the error below happens:

Task :app:processAot
12:04:29.496 [main] DEBUG reactor.util.Loggers -- Using Slf4j logging framework
2023-04-11 12:04:30.250 INFO  app=security-token-service, traceId=, spanId=, t=background-preinit, class=org.hibernate.validator.internal.util.Version, HV000001: Hibernate Validator 8.0.0.Final 

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

2023-04-11 12:04:30.335 INFO  app=security-token-service, traceId=, spanId=, t=main, class=s.token.service.SecurityTokenServiceApplicationKt, Starting SecurityTokenServiceApplicationKt using Java 17.0.6 with PID 71943 (/Users/rgfirmino/workspace/security-token-service/app/build/classes/kotlin/main started by rgfirmino in /Users/rgfirmino/workspace/security-token-service/app) 
2023-04-11 12:04:30.337 INFO  app=security-token-service, traceId=, spanId=, t=main, class=s.token.service.SecurityTokenServiceApplicationKt, No active profile set, falling back to 1 default profile: "default" 
Exception in thread "main" java.lang.IllegalArgumentException: invalid type parameter: void
        at org.springframework.javapoet.Util.checkArgument(Util.java:53)
        at org.springframework.javapoet.ParameterizedTypeName.<init>(ParameterizedTypeName.java:51)
        at org.springframework.javapoet.ParameterizedTypeName.<init>(ParameterizedTypeName.java:38)
        at org.springframework.javapoet.ParameterizedTypeName.get(ParameterizedTypeName.java:119)
        at org.springframework.beans.factory.aot.InstanceSupplierCodeGenerator.buildGetInstanceMethodForFactoryMethod(InstanceSupplierCodeGenerator.java:257)
        at org.springframework.beans.factory.aot.InstanceSupplierCodeGenerator.lambda$generateCodeForAccessibleFactoryMethod$2(InstanceSupplierCodeGenerator.java:228)
        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.InstanceSupplierCodeGenerator.generateGetInstanceSupplierMethod(InstanceSupplierCodeGenerator.java:331)
        at org.springframework.beans.factory.aot.InstanceSupplierCodeGenerator.generateCodeForAccessibleFactoryMethod(InstanceSupplierCodeGenerator.java:227)
        at org.springframework.beans.factory.aot.InstanceSupplierCodeGenerator.generateCodeForFactoryMethod(InstanceSupplierCodeGenerator.java:206)
        at org.springframework.beans.factory.aot.InstanceSupplierCodeGenerator.generateCode(InstanceSupplierCodeGenerator.java:98)
        at org.springframework.beans.factory.aot.DefaultBeanRegistrationCodeFragments.generateInstanceSupplierCode(DefaultBeanRegistrationCodeFragments.java:206)
        at org.springframework.beans.factory.aot.BeanRegistrationCodeGenerator.generateCode(BeanRegistrationCodeGenerator.java:89)
        at org.springframework.beans.factory.aot.BeanDefinitionMethodGenerator.lambda$generateBeanDefinitionMethod$3(BeanDefinitionMethodGenerator.java:194)
        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:188)
        at org.springframework.beans.factory.aot.BeanDefinitionMethodGenerator.generateBeanDefinitionMethod(BeanDefinitionMethodGenerator.java:109)
        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:80)

> Task :app:processAot FAILED

Even using --stacktrace or --debug the error message remains the same. I have already removed all VOID methods, however, without success. I can't know which method the error refers to.

Does anyone have any idea how I can try to make the error more specific?

  • UPDATE a lot of dependencies

  • not effective

  • REMOVE a lot of dependencies

  • not effective

  • Used stacktrace and debug definitions

  • not effective

1 Answers1

0

I still haven't figured out how to make the AOT error messages more specific, but I found my problem. If anyone else needs it, AOT doesn't understand spring beans with VOID return.

I had a @Bean that didn't return anything:

@Configuration
class BouncyCastleConfig {

  @Bean
  fun addProviders() {
    Security.addProvider(BouncyCastleProvider())
  }
}

I switched to something static:

@Configuration
class BouncyCastleConfig {

  init {
    Security.addProvider(BouncyCastleProvider())
  }
}
  • an `@Bean` with a `void` return type is strange and is probably a sign you are doing something wrong and should use proper initiailization callbacks instead of this. – M. Deinum Apr 12 '23 at 06:31
  • 1
    yes, it really was an error, but the reported problem is not the Bean itself, it is the little information in the stacktrace in processAOT to inform what is wrong – Rafael Firmino Apr 12 '23 at 12:44