Environment: OS: Windows 10 X64 22H2 JDK: GraalVM CE 22.3.1 with Open JDK 19 Maven: 3.9.0 SpringBoot: 3.0.4
I followed the wiki and input the command below
java '-Dspring.aot.enabled=true' '-agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image' -jar .\target\aot-tracing-agent-test-0.0.1-SNAPSHOT.jar
then I got this error msg.
2023-03-18T12:42:16.086+08:00 ERROR 13108 --- [ main] o.s.boot.SpringApplication : Application run failed
java.lang.IllegalArgumentException: Could not find class [com.example.aottracingagenttest.AotTracingAgentTestApplication__ApplicationContextInitializer]
at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:333) ~[spring-core-6.0.6.jar!/:6.0.6]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65) ~[aot-tracing-agent-test-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]Caused by: java.lang.ClassNotFoundException: com.example.aottracingagenttest.AotTracingAgent at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65) ~[aot-tracing-agent-test-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]Caused by: java.lang.ClassNotFoundException: com.example.aottracingagenttest.AotTracingAgent at java.base/java.lang.Class.forName(Class.java:474) ~[na:na]
at org.springframework.util.ClassUtils.forName(ClassUtils.java:283) ~[spring-core-6.0.6.jar!/:6.0.6]
at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:323) ~[spring-core-6.0.6.jar!/:6.0.6]
... 15 common frames omitted
I have gotten this problem since the realse of SpringBoot 3.0.0
by the way, if I only change the arg -Dspring.aot.enabled=true to -DspringAot=true, the application will start normally.
here is my test project
Comment From: wilkinsona
The absence of AotTracingAgentTestApplication__ApplicationContextInitializer suggests that AOT processing has not been performed when you built the jar. As you are using spring-boot-starter-parent you can use the native profile:
mvn -Pnative package
This will produce an AOT-processed jar file that contains AotTracingAgentTestApplication__ApplicationContextInitializer.