Skip to content

Spring native: Built image fails to run straight out of the box #36040

Closed as not planned
@Haarolean

Description

@Haarolean

Hi,

I haven't touched spring-native for a few years, and it seems to be broken even more than it used to be.

While trying to solve other related problems, I tried to run a demo app from scratch, which failed drastically.

Set up:

  1. start.spring.io
  2. maven, boot 3.1.0, java, jar, 17
  3. dependencies: graalvm, configuration processor, devtools, lombok, jpa, validation

Outcome:

  1. Jar runs fine
  2. Native image doesn't:
 :: Spring Boot ::                (v3.1.0)

15:17:49.314 [main] ERROR org.springframework.boot.SpringApplication -- Application run failed
java.lang.IllegalArgumentException: Could not find class [com.example.demo.DemoApplication__ApplicationContextInitializer]
	at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:334)
	at org.springframework.context.aot.AotApplicationContextInitializer.instantiateInitializer(AotApplicationContextInitializer.java:80)
	at org.springframework.context.aot.AotApplicationContextInitializer.initialize(AotApplicationContextInitializer.java:71)
	at org.springframework.context.aot.AotApplicationContextInitializer.lambda$forInitializerClasses$0(AotApplicationContextInitializer.java:61)
	at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:606)
	at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:386)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:310)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1305)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1294)
	at com.example.demo.DemoApplication.main(DemoApplication.java:10)
Caused by: java.lang.ClassNotFoundException: com.example.demo.DemoApplication__ApplicationContextInitializer
	at [email protected]/java.lang.Class.forName(DynamicHub.java:1132)
	at org.springframework.util.ClassUtils.forName(ClassUtils.java:284)
	at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:324)
	... 9 common frames omitted

I tried using spring-core 6.0.10-SNAPSHOT as has been suggested here, with no luck.
I have published the sources so you can save some time to reproduce the issue: here

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions