spring-projects / spring-framework

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

AOT processing fails with `@Bean` factory method with `void` return type #30991

Closed robozb closed 1 year ago

robozb commented 1 year ago

Dear All,

I'd like to convert my app to a GraalVM native image, but I get this exception without more detailed information about the problem in my code.

Thank You so much for any help!

Bela

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

2023-08-03 18:16:58 INFO  Logger: .hi.validator.internal.util.Version Message: >>> HV000001: Hibernate Validator 8.0.1.Final <<<
2023-08-03 18:16:58 INFO  Logger:         h.wf.vsm.ManagerApplication Message: >>> Starting ManagerApplication using Java 17.0.6 with PID 10640 (D:\Kivitelezes2\VauStaff\vsm-backend\target\classes started by Beci in D:\Kivitelezes2\VauStaff\vsm-backend) <<<
2023-08-03 18:16:58 INFO  Logger:         h.wf.vsm.ManagerApplication Message: >>> The following 1 profile is active: "dev" <<<
2023-08-03 18:16:59 INFO  Logger: fig.RepositoryConfigurationDelegate Message: >>> Bootstrapping Spring Data JPA repositories in DEFAULT mode. <<<
2023-08-03 18:16:59 INFO  Logger: fig.RepositoryConfigurationDelegate Message: >>> Finished Spring Data repository scanning in 100 ms. Found 8 JPA repository interfaces. <<<
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:258)
    at org.springframework.beans.factory.aot.InstanceSupplierCodeGenerator.lambda$generateCodeForAccessibleFactoryMethod$2(InstanceSupplierCodeGenerator.java:229)
    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:332)
    at org.springframework.beans.factory.aot.InstanceSupplierCodeGenerator.generateCodeForAccessibleFactoryMethod(InstanceSupplierCodeGenerator.java:228)
    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:227)
    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:93)
    at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721)
    at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution.generateRegisterBeanDefinitionsMethod(BeanRegistrationsAotContribution.java:91)
    at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution.lambda$applyTo$1(BeanRegistrationsAotContribution.java:76)
    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:75)
    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)
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time:  12.464 s
Finished at: 2023-08-03T18:17:04+02:00
------------------------------------------------------------------------
Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.1.2:process-aot (process-aot) on project vsm-backend: Process terminated with exit code: 1 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.1.2:process-aot (process-aot) on project vsm-backend: Process terminated with exit code: 1
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:375)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions (MojoExecutor.java:508)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:345)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:47)
    at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:156)
    at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:72)
Caused by: org.apache.maven.plugin.MojoExecutionException: Process terminated with exit code: 1
    at org.springframework.boot.maven.AbstractAotMojo.execute (AbstractAotMojo.java:108)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions (MojoExecutor.java:508)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:345)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:47)
    at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:156)
    at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:72)
Caused by: org.apache.maven.plugin.MojoExecutionException: Process terminated with exit code: 1
    at org.springframework.boot.maven.JavaProcessExecutor.run (JavaProcessExecutor.java:74)
    at org.springframework.boot.maven.AbstractAotMojo.generateAotAssets (AbstractAotMojo.java:125)
    at org.springframework.boot.maven.ProcessAotMojo.executeAot (ProcessAotMojo.java:94)
    at org.springframework.boot.maven.AbstractAotMojo.execute (AbstractAotMojo.java:105)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions (MojoExecutor.java:508)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:345)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:47)
    at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:156)
    at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:72)

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
robozb commented 1 year ago

Another interesting thing: I could create a native image on a separate virtual machine with GraalVM: native-image -jar vsm.jar but the result is interesting :) I can't run the executable output without the original jar when I try to run without that I got this error:

Error: Could not find or load main class org.springframework.boot.loader.JarLauncher
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.loader.JarLauncher

With the original jar it works perfectly, but I can't put it or (these) into a docker container, all the time I got this error:

exec ./vsm: no such file or directory

But I know the files are there! The Dockerfile:

FROM alpine:latest

COPY vsm /app/
COPY vsm.jar /app/

WORKDIR /app

RUN chmod +x vsm
RUN chmod +x vsm.jar

CMD ["./vsm"]

Building the docker image

root@ubuntu-docker:~/tmp3# ./build.sh
[+] Building 4.7s (11/11) FINISHED                                                                                                            docker:default
 => [internal] load build definition from Dockerfile                                                                                                    0.0s
 => => transferring dockerfile: 159B                                                                                                                    0.0s
 => [internal] load .dockerignore                                                                                                                       0.0s
 => => transferring context: 2B                                                                                                                         0.0s
 => [internal] load metadata for docker.io/library/alpine:latest                                                                                        0.8s
 => CACHED [1/6] FROM docker.io/library/alpine:latest@sha256:82d1e9d7ed48a7523bdebc18cf6290bdb97b82302a8a9c27d4fe885949ea94d1                           0.0s
 => [internal] load build context                                                                                                                       0.0s
 => => transferring context: 56B                                                                                                                        0.0s
 => [2/6] COPY vsm /app/                                                                                                                                0.1s
 => [3/6] COPY vsm.jar /app/                                                                                                                            0.4s
 => [4/6] WORKDIR /app                                                                                                                                  0.1s
 => [5/6] RUN chmod +x vsm                                                                                                                              0.8s
 => [6/6] RUN chmod +x vsm.jar                                                                                                                          1.0s
 => exporting to image                                                                                                                                  1.5s
 => => exporting layers                                                                                                                                 1.5s
 => => writing image sha256:cc0d8d59261ec2adeae6b991223811968af5addaaf67d1756f60e95d5f1a8837                                                            0.0s
 => => naming to wfs.hu/vsm/vsm-linux:0.0.3                                                                                                             0.0s
build ok
CONT ID: c942f10cada2325582126d946491bda8298664cff3d99ffd9c45187394446f4f
exec ./vsm: no such file or directory

The image filesystem:

image

image

Thanks for your help in advance!

Bela

robozb commented 1 year ago

Whether is my project too complex for creating GraalVM native image?

--- maven-dependency-plugin:3.5.0:tree (default-cli) @ vsm-backend ---
hu.wfs.vau:vsm-backend:jar:0.0.11-SNAPSHOT
+- org.springframework.boot:spring-boot-starter-web:jar:3.1.2:compile
|  +- org.springframework.boot:spring-boot-starter:jar:3.1.2:compile
|  |  +- jakarta.annotation:jakarta.annotation-api:jar:2.1.1:compile
|  |  \- org.yaml:snakeyaml:jar:1.33:compile
|  +- org.springframework.boot:spring-boot-starter-json:jar:3.1.2:compile
|  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.15.2:compile
|  |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.15.2:compile
|  +- org.springframework.boot:spring-boot-starter-tomcat:jar:3.1.2:compile
|  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:10.1.11:compile
|  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:10.1.11:compile
|  +- org.springframework:spring-web:jar:6.0.11:compile
|  |  \- org.springframework:spring-beans:jar:6.0.11:compile
|  \- org.springframework:spring-webmvc:jar:6.0.11:compile
|     +- org.springframework:spring-context:jar:6.0.11:compile
|     \- org.springframework:spring-expression:jar:6.0.11:compile
+- org.springframework.boot:spring-boot-devtools:jar:3.1.2:runtime
|  +- org.springframework.boot:spring-boot:jar:3.1.2:compile
|  \- org.springframework.boot:spring-boot-autoconfigure:jar:3.1.2:compile
+- org.springframework.boot:spring-boot-starter-test:jar:3.1.2:test
|  +- org.springframework.boot:spring-boot-test:jar:3.1.2:test
|  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:3.1.2:test
|  +- com.jayway.jsonpath:json-path:jar:2.8.0:test
|  +- jakarta.xml.bind:jakarta.xml.bind-api:jar:4.0.0:compile
|  |  \- jakarta.activation:jakarta.activation-api:jar:2.1.2:compile
|  +- net.minidev:json-smart:jar:2.4.11:test
|  |  \- net.minidev:accessors-smart:jar:2.4.11:test
|  |     \- org.ow2.asm:asm:jar:9.3:compile
|  +- org.assertj:assertj-core:jar:3.24.2:test
|  |  \- net.bytebuddy:byte-buddy:jar:1.14.5:runtime
|  +- org.hamcrest:hamcrest:jar:2.2:test
|  +- org.junit.jupiter:junit-jupiter:jar:5.9.3:test
|  |  +- org.junit.jupiter:junit-jupiter-api:jar:5.9.3:test
|  |  |  +- org.opentest4j:opentest4j:jar:1.2.0:test
|  |  |  +- org.junit.platform:junit-platform-commons:jar:1.9.3:test
|  |  |  \- org.apiguardian:apiguardian-api:jar:1.1.2:test
|  |  +- org.junit.jupiter:junit-jupiter-params:jar:5.9.3:test
|  |  \- org.junit.jupiter:junit-jupiter-engine:jar:5.9.3:test
|  |     \- org.junit.platform:junit-platform-engine:jar:1.9.3:test
|  +- org.mockito:mockito-core:jar:5.3.1:test
|  |  +- net.bytebuddy:byte-buddy-agent:jar:1.14.5:test
|  |  \- org.objenesis:objenesis:jar:3.3:test
|  +- org.mockito:mockito-junit-jupiter:jar:5.3.1:test
|  +- org.skyscreamer:jsonassert:jar:1.5.1:test
|  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
|  +- org.springframework:spring-core:jar:6.0.11:compile
|  |  \- org.springframework:spring-jcl:jar:6.0.11:compile
|  +- org.springframework:spring-test:jar:6.0.11:test
|  \- org.xmlunit:xmlunit-core:jar:2.9.1:test
+- org.springframework.boot:spring-boot-starter-log4j2:jar:3.1.2:compile
|  +- org.apache.logging.log4j:log4j-slf4j2-impl:jar:2.20.0:compile
|  |  \- org.apache.logging.log4j:log4j-api:jar:2.20.0:compile
|  +- org.apache.logging.log4j:log4j-core:jar:2.20.0:compile
|  \- org.apache.logging.log4j:log4j-jul:jar:2.20.0:compile
+- org.slf4j:log4j-over-slf4j:jar:2.0.7:compile
|  \- org.slf4j:slf4j-api:jar:2.0.7:compile
+- net.bull.javamelody:javamelody-spring-boot-starter:jar:2.0.0:compile
|  +- net.bull.javamelody:javamelody-core:jar:2.0.0:compile
|  |  \- org.jrobin:jrobin:jar:1.5.9:compile
|  \- org.springframework.boot:spring-boot-starter-aop:jar:3.1.2:compile
|     \- org.aspectj:aspectjweaver:jar:1.9.19:compile
+- org.springframework.boot:spring-boot-starter-data-jpa:jar:3.1.2:compile
|  +- org.springframework.boot:spring-boot-starter-jdbc:jar:3.1.2:compile
|  |  +- com.zaxxer:HikariCP:jar:5.0.1:compile
|  |  \- org.springframework:spring-jdbc:jar:6.0.11:compile
|  +- org.hibernate.orm:hibernate-core:jar:6.2.6.Final:compile
|  |  +- jakarta.persistence:jakarta.persistence-api:jar:3.1.0:compile
|  |  +- jakarta.transaction:jakarta.transaction-api:jar:2.0.1:compile
|  |  +- org.jboss.logging:jboss-logging:jar:3.5.3.Final:compile
|  |  +- org.hibernate.common:hibernate-commons-annotations:jar:6.0.6.Final:runtime
|  |  +- io.smallrye:jandex:jar:3.0.5:runtime
|  |  +- com.fasterxml:classmate:jar:1.5.1:compile
|  |  +- org.glassfish.jaxb:jaxb-runtime:jar:4.0.3:compile
|  |  |  \- org.glassfish.jaxb:jaxb-core:jar:4.0.3:compile
|  |  |     +- org.eclipse.angus:angus-activation:jar:2.0.1:runtime
|  |  |     +- org.glassfish.jaxb:txw2:jar:4.0.3:compile
|  |  |     \- com.sun.istack:istack-commons-runtime:jar:4.1.2:compile
|  |  +- jakarta.inject:jakarta.inject-api:jar:2.0.1:runtime
|  |  \- org.antlr:antlr4-runtime:jar:4.10.1:compile
|  +- org.springframework.data:spring-data-jpa:jar:3.1.2:compile
|  |  +- org.springframework.data:spring-data-commons:jar:3.1.2:compile
|  |  +- org.springframework:spring-orm:jar:6.0.11:compile
|  |  \- org.springframework:spring-tx:jar:6.0.11:compile
|  \- org.springframework:spring-aspects:jar:6.0.11:compile
+- org.springframework.boot:spring-boot-starter-security:jar:3.1.2:compile
|  +- org.springframework:spring-aop:jar:6.0.11:compile
|  +- org.springframework.security:spring-security-config:jar:6.1.2:compile
|  \- org.springframework.security:spring-security-web:jar:6.1.2:compile
+- org.springframework.boot:spring-boot-starter-validation:jar:3.1.2:compile
|  +- org.apache.tomcat.embed:tomcat-embed-el:jar:10.1.11:compile
|  \- org.hibernate.validator:hibernate-validator:jar:8.0.1.Final:compile
|     \- jakarta.validation:jakarta.validation-api:jar:3.0.2:compile
+- org.springframework.security:spring-security-test:jar:6.1.2:test
|  \- org.springframework.security:spring-security-core:jar:6.1.2:compile
|     \- org.springframework.security:spring-security-crypto:jar:6.1.2:compile
+- org.springframework.boot:spring-boot-starter-oauth2-resource-server:jar:3.1.2:compile
|  +- org.springframework.security:spring-security-oauth2-resource-server:jar:6.1.2:compile
|  |  \- org.springframework.security:spring-security-oauth2-core:jar:6.1.2:compile
|  \- org.springframework.security:spring-security-oauth2-jose:jar:6.1.2:compile
|     \- com.nimbusds:nimbus-jose-jwt:jar:9.31:compile
|        \- com.github.stephenc.jcip:jcip-annotations:jar:1.0-1:compile
+- org.springframework.boot:spring-boot-starter-thymeleaf:jar:3.1.2:compile
|  \- org.thymeleaf:thymeleaf-spring6:jar:3.1.1.RELEASE:compile
|     \- org.thymeleaf:thymeleaf:jar:3.1.1.RELEASE:compile
|        +- org.attoparser:attoparser:jar:2.0.6.RELEASE:compile
|        \- org.unbescape:unbescape:jar:1.1.6.RELEASE:compile
+- org.thymeleaf.extras:thymeleaf-extras-springsecurity6:jar:3.1.1.RELEASE:compile
+- org.springframework.boot:spring-boot-starter-actuator:jar:3.1.2:compile
|  +- org.springframework.boot:spring-boot-actuator-autoconfigure:jar:3.1.2:compile
|  |  \- org.springframework.boot:spring-boot-actuator:jar:3.1.2:compile
|  +- io.micrometer:micrometer-observation:jar:1.11.2:compile
|  |  \- io.micrometer:micrometer-commons:jar:1.11.2:compile
|  \- io.micrometer:micrometer-core:jar:1.11.2:compile
|     +- org.hdrhistogram:HdrHistogram:jar:2.1.12:runtime
|     \- org.latencyutils:LatencyUtils:jar:2.0.3:runtime
+- com.sun.mail:javax.mail:jar:1.6.2:compile
|  \- javax.activation:activation:jar:1.1:compile
+- org.passay:passay:jar:1.6.3:compile
+- com.sun.activation:jakarta.activation:jar:2.0.0:compile
+- hu.wfs.lib.halozat:WFSLib_Halozat:jar:2.7.0:compile
|  +- hu.wfs.lib.biztonsag:WFSLib_Biztonsag:jar:2.5.3:compile
|  |  +- hu.wfs.lib.altalanos:WFSLib_Altalanos:jar:2.7.2:compile
|  |  |  +- org.apache.velocity:velocity:jar:1.5:compile
|  |  |  |  +- commons-collections:commons-collections:jar:3.1:compile
|  |  |  |  +- commons-lang:commons-lang:jar:2.1:compile
|  |  |  |  \- oro:oro:jar:2.0.8:compile
|  |  |  +- net.sourceforge.jexcelapi:jxl:jar:2.6.12:compile
|  |  |  +- org.apache.poi:poi:jar:3.17:compile
|  |  |  |  \- org.apache.commons:commons-collections4:jar:4.1:compile
|  |  |  +- org.apache.poi:poi-ooxml:jar:3.17:compile
|  |  |  |  +- org.apache.poi:poi-ooxml-schemas:jar:3.17:compile
|  |  |  |  |  \- org.apache.xmlbeans:xmlbeans:jar:2.6.0:compile
|  |  |  |  |     \- stax:stax-api:jar:1.0.1:compile
|  |  |  |  \- com.github.virtuald:curvesapi:jar:1.04:compile
|  |  |  +- com.sun.xml.bind:jaxb-core:jar:4.0.3:compile
|  |  |  \- com.sun.xml.bind:jaxb-impl:jar:4.0.3:compile
|  |  +- kulsojar.bcprov_jdk16_jeloletlen_1_43:bcprov_jdk16_jeloletlen_1_43:jar:1.0.0:compile
|  |  +- ch.ethz.ganymed:ganymed-ssh2:jar:build210:compile
|  |  +- J2SSHCommon:J2SSHCommon:jar:0.2.9-patched:system
|  |  +- J2SSHCore:J2SSHCore:jar:0.2.9-patched:system
|  |  +- commons-httpclient:commons-httpclient:jar:3.0.1:compile
|  |  \- commons-logging:commons-logging:jar:1.0.4:compile
|  +- javax.mail:javax.mail-api:jar:1.6.2:compile
|  +- javax.xml.ws:jaxws-api:jar:2.3.1:compile
|  |  +- javax.xml.bind:jaxb-api:jar:2.3.1:compile
|  |  |  \- javax.activation:javax.activation-api:jar:1.2.0:compile
|  |  +- javax.xml.soap:javax.xml.soap-api:jar:1.4.0:compile
|  |  \- javax.annotation:javax.annotation-api:jar:1.3.2:compile
|  \- org.jsoup:jsoup:jar:1.13.1:compile
+- org.projectlombok:lombok:jar:1.18.28:compile
+- org.keycloak:keycloak-admin-client:jar:21.0.1:compile
|  +- org.keycloak:keycloak-core:jar:21.0.1:compile
|  +- org.keycloak:keycloak-common:jar:21.0.1:compile
|  +- org.jboss.resteasy:resteasy-client:jar:4.7.7.Final:compile
|  |  +- org.jboss.resteasy:resteasy-client-api:jar:4.7.7.Final:compile
|  |  +- org.jboss.resteasy:resteasy-core-spi:jar:4.7.7.Final:compile
|  |  |  \- org.jboss.spec.javax.annotation:jboss-annotations-api_1.3_spec:jar:2.0.1.Final:compile
|  |  +- org.jboss.resteasy:resteasy-core:jar:4.7.7.Final:compile
|  |  |  +- com.ibm.async:asyncutil:jar:0.1.0:compile
|  |  |  \- io.smallrye.config:smallrye-config:jar:2.3.0:compile
|  |  |     \- io.smallrye.config:smallrye-config-core:jar:2.3.0:compile
|  |  |        +- org.eclipse.microprofile.config:microprofile-config-api:jar:2.0:compile
|  |  |        +- io.smallrye.common:smallrye-common-annotation:jar:1.6.0:compile
|  |  |        +- io.smallrye.common:smallrye-common-expression:jar:1.6.0:compile
|  |  |        |  \- io.smallrye.common:smallrye-common-function:jar:1.6.0:compile
|  |  |        +- io.smallrye.common:smallrye-common-constraint:jar:1.6.0:compile
|  |  |        +- io.smallrye.common:smallrye-common-classloader:jar:1.6.0:compile
|  |  |        \- io.smallrye.config:smallrye-config-common:jar:2.3.0:compile
|  |  +- org.apache.httpcomponents:httpclient:jar:4.5.13:compile
|  |  |  \- org.apache.httpcomponents:httpcore:jar:4.4.16:compile
|  |  +- commons-codec:commons-codec:jar:1.15:compile
|  |  +- commons-io:commons-io:jar:2.9.0:compile
|  |  +- org.jboss.spec.javax.ws.rs:jboss-jaxrs-api_2.1_spec:jar:2.0.1.Final:compile
|  |  \- org.reactivestreams:reactive-streams:jar:1.0.4:compile
|  +- org.jboss.resteasy:resteasy-multipart-provider:jar:4.7.7.Final:compile
|  |  +- com.sun.mail:jakarta.mail:jar:1.6.5:compile
|  |  +- org.apache.james:apache-mime4j-dom:jar:0.8.3:compile
|  |  |  \- org.apache.james:apache-mime4j-core:jar:0.8.3:compile
|  |  \- org.apache.james:apache-mime4j-storage:jar:0.8.3:compile
|  +- org.jboss.resteasy:resteasy-jackson2-provider:jar:4.7.7.Final:compile
|  |  +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.15.2:compile
|  |  |  +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.15.2:compile
|  |  |  \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.15.2:compile
|  |  \- com.github.java-json-tools:json-patch:jar:1.13:compile
|  |     +- com.github.java-json-tools:msg-simple:jar:1.2:compile
|  |     |  \- com.github.java-json-tools:btf:jar:1.3:compile
|  |     \- com.github.java-json-tools:jackson-coreutils:jar:2.0:compile
|  \- org.jboss.resteasy:resteasy-jaxb-provider:jar:4.7.7.Final:compile
|     \- org.jboss.spec.javax.xml.bind:jboss-jaxb-api_2.3_spec:jar:2.0.0.Final:compile
+- com.mysql:mysql-connector-j:jar:8.0.33:runtime
+- io.micrometer:micrometer-registry-prometheus:jar:1.11.2:compile
|  \- io.prometheus:simpleclient_common:jar:0.16.0:compile
|     \- io.prometheus:simpleclient:jar:0.16.0:compile
|        +- io.prometheus:simpleclient_tracer_otel:jar:0.16.0:compile
|        |  \- io.prometheus:simpleclient_tracer_common:jar:0.16.0:compile
|        \- io.prometheus:simpleclient_tracer_otel_agent:jar:0.16.0:compile
+- com.github.javafaker:javafaker:jar:1.0.2:compile
|  +- org.apache.commons:commons-lang3:jar:3.12.0:compile
|  +- org.yaml:snakeyaml:jar:android:1.23:compile
|  \- com.github.mifmif:generex:jar:1.0.2:compile
|     \- dk.brics.automaton:automaton:jar:1.11-8:compile
+- org.modelmapper:modelmapper:jar:3.0.0:compile
+- com.fasterxml.jackson.core:jackson-databind:jar:2.15.2:compile
|  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.15.2:compile
|  \- com.fasterxml.jackson.core:jackson-core:jar:2.15.2:compile
\- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.15.2:compile
snicoll commented 1 year ago

You've hit a bug in the AOT engine:

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:258)
    at org.springframework.beans.factory.aot.InstanceSupplierCodeGenerator.lambda$generateCodeForAccessibleFactoryMethod$2(InstanceSupplierCodeGenerator.java:229)
    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)

I am going to transfer this to framework as I'd like to be able to reproduce it.

snicoll commented 1 year ago

If you can't share a sample that reproduces the problem, it would be nice to debug the bean definition that leads to think that the return type is void. Do you have any @Bean method that returns void by any chance?

You can debug by enabling the remote debugger, something like:

mvn native:compile -Pnative -Dspring-boot.aot.jvmArguments="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005"

You can then put a debug breakpoint in InstanceSupplierCodeGenerator line 258. Once you get the beanName that has a void suppliedType, please share its configuration so that we can better understand what's going on. Thanks!

robozb commented 1 year ago

Dear @snicoll ,

First of all, thank you so much for your kind help! I will try it tomorrow.

Best Regards

Bela

robozb commented 1 year ago

Dear @snicoll,

You were right, there was a @Component class with @Bean annotated void return type method.

The building was successful, but new problems arised related to Log4j2 and Embedded Tomcat. So, a more complex project is more challenging.

snicoll commented 1 year ago

You were right, there was a https://github.com/component class with @bean annotated void return type method.

And what does that bean do? Was it a mistake or something legit? I'd like to understand it to see what we're going to do about this. Please provide the details.

but new problems arised

The issue tracker is not a support forum. We're going to focus on the original exception you've described here. If it turns out another issue is necessary, then we can do that but please don't post screenshots like that, it really isn't useful. And Log4j2 isn't supported unfortunately.

Can you please share the detail of that @Bean with void return type? Thanks!

robozb commented 1 year ago

Dear @snicoll,

OK :) I understand! I removed the not-related contents!

This caused the problem. When I removed it the build was successful:

package hu.wfs.vsm.konfig;

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.TimeZone;

@Configuration
public class TimeZoneConfig implements WebMvcConfigurer {

    @Bean
    public void setTimeZone() {
        TimeZone.setDefault(TimeZone.getTimeZone("Europe/Budapest"));
        System.out.println("TimeZone: " + TimeZone.getDefault());
    }
}
robozb commented 1 year ago

But I have to comment it, the final image wasn't useful, because there was an error with the embeded Tomcat as well.

I try to reproduce the problem later.

snicoll commented 1 year ago

Defining a bean with void return type should not be permitted. We've decided to fail fast and reject that arrangement, regardless of AOT.

This issue is now superseded by #31007