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!

@mhalbritter mhalbritter modified the milestones: 3.2.x, 3.2.0 Nov 7, 2023
@mhalbritter mhalbritter changed the title Report friendly error for starting application with AOT mode but not AOT-processed Report friendly error when failing to find AOT initializer Nov 7, 2023
ndwlocatieservices added a commit to ndwnu/nls-routing-map-matcher that referenced this pull request Nov 6, 2024
…o v3.2.0

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [nu.ndw.nls.geometry:nls-geometry](https://spring.io/projects/spring-boot) ([source](https://github.com/spring-projects/spring-boot)) | compile | minor | `3.1.2` -> `3.2.0` |

---

### Release Notes

<details>
<summary>spring-projects/spring-boot (nu.ndw.nls.geometry:nls-geometry)</summary>

### [`v3.2.0`](https://github.com/spring-projects/spring-boot/releases/tag/v3.2.0)

[Compare Source](spring-projects/spring-boot@v3.1.2...v3.2.0)

#### ⭐ New Features

-   Auto-configure observations for RestClients [#&#8203;38500](spring-projects/spring-boot#38500)
-   Add support for Oracle Free, the replacement for Oracle XE, with Testcontainers and Docker Compose [#&#8203;38476](spring-projects/spring-boot#38476)
-   Provide dependency management for org.crac:crac [#&#8203;38378](spring-projects/spring-boot#38378)
-   Add new properties for Liquibase 4.24.0 [#&#8203;38274](spring-projects/spring-boot#38274)
-   Provide a way to create custom ApplicationContextFactory in SpringBootContextLoader [#&#8203;38205](spring-projects/spring-boot#38205)
-   Report friendly error when failing to find AOT initializer [#&#8203;38188](spring-projects/spring-boot#38188)

#### 🐞 Bug Fixes

-   Annotation based ConditionalOnBean checks can cause early initialization of FactoryBeans [#&#8203;38507](spring-projects/spring-boot#38507)
-   CRaC restoration fails when Actuator's running on a separate port [#&#8203;38502](spring-projects/spring-boot#38502)
-   App that depends on Tomcat and on Jetty's websocket-server module fails to start with IllegalStateException: WebSocketComponents has not been created [#&#8203;38286](spring-projects/spring-boot#38286)
-   App fails to start with a NoSuchMethodError when using Flyway 10.0.0 [#&#8203;38268](spring-projects/spring-boot#38268)
-   MeterRegistry throws BeanCreationNotAllowedException on shutdown [#&#8203;38240](spring-projects/spring-boot#38240)
-   Resolution of productionRuntimeClasspath configuration may select the wrong variant and contain a dependency's source jar [#&#8203;38233](spring-projects/spring-boot#38233)
-   Docker JSON parsing fails on certain locales [#&#8203;38220](spring-projects/spring-boot#38220)
-   FileNotFoundException is thrown serving resources due to JarUrlConnection.getLastModified() returning zero [#&#8203;38204](spring-projects/spring-boot#38204)
-   Failed to extract parameter names exception thrown when binding with non-enumerable property source [#&#8203;38201](https://github.com/spring-projects/spring...
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.

4 participants