Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report friendly error when failing to find AOT initializer #38188

Closed
wants to merge 1 commit into from

Conversation

quaff
Copy link
Contributor

@quaff quaff commented Nov 3, 2023

Error is reported as:

java.lang.IllegalArgumentException: You are starting application with AOT mode but not AOT-processed, please build your application with AOT first. Or remove system property 'spring.aot.enabled=true' to run as regular mode.
	at org.springframework.boot.SpringApplication.addAotGeneratedInitializerIfNecessary(SpringApplication.java:441) ~[main/:?]
	at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:396) ~[main/:?]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:322) ~[main/:?]

instead of:

java.lang.IllegalArgumentException: Could not find class [org.springframework.boot.SpringApplicationTests$TestSpringApplication__ApplicationContextInitializer]
	at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:355) ~[spring-core-6.1.0-RC2.jar:6.1.0-RC2]
	at org.springframework.context.aot.AotApplicationContextInitializer.instantiateInitializer(AotApplicationContextInitializer.java:80) ~[spring-context-6.1.0-RC2.jar:6.1.0-RC2]
	at org.springframework.context.aot.AotApplicationContextInitializer.initialize(AotApplicationContextInitializer.java:71) ~[spring-context-6.1.0-RC2.jar:6.1.0-RC2]
	at org.springframework.context.aot.AotApplicationContextInitializer.lambda$forInitializerClasses$0(AotApplicationContextInitializer.java:61) ~[spring-context-6.1.0-RC2.jar:6.1.0-RC2]
	at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:623) ~[main/:?]
	at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:397) ~[main/:?]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:322) ~[main/:?]
	... 
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.SpringApplicationTests$TestSpringApplication__ApplicationContextInitializer
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[?:?]
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[?:?]
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525) ~[?:?]
	at java.base/java.lang.Class.forName0(Native Method) ~[?:?]
	at java.base/java.lang.Class.forName(Class.java:467) ~[?:?]
	at org.springframework.util.ClassUtils.forName(ClassUtils.java:304) ~[spring-core-6.1.0-RC2.jar:6.1.0-RC2]
	at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:345) ~[spring-core-6.1.0-RC2.jar:6.1.0-RC2]
	... 

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 3, 2023
@philwebb philwebb added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 6, 2023
@philwebb philwebb added this to the 3.2.x milestone Nov 6, 2023
@philwebb philwebb added the for: merge-with-amendments Needs some changes when we merge label Nov 6, 2023
@mhalbritter mhalbritter self-assigned this Nov 7, 2023
@mhalbritter
Copy link
Contributor

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: merge-with-amendments Needs some changes when we merge type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants