Skip to content

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

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

Closed
Haarolean opened this issue Jun 23, 2023 · 4 comments
Closed

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

Haarolean opened this issue Jun 23, 2023 · 4 comments
Labels
status: invalid An issue that we don't feel is valid

Comments

@Haarolean
Copy link
Contributor

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

@Haarolean
Copy link
Contributor Author

Related: #32918, but with java, not kotlin.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 23, 2023
@wilkinsona
Copy link
Member

It sounds like your application hasn't been AOT-processed, perhaps because it was not built with the correct command. Did you use ./mvnw native:compile -Pnative as described in the HELP.md file of the project generated by start.spring.io?

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Jun 23, 2023
@spring-projects-issues
Copy link
Collaborator

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Jun 30, 2023
@Haarolean
Copy link
Contributor Author

Hi Andy, thanks for your swift reply.
Indeed, I tried to rebuild the image again, the same way with mvn clean package -Pnative, but couldn't reproduce this anymore.
Got a lot of frustration with trying to get native images working, probably haven't paid enough attention after fighting with this for days.
Thanks again!

@Haarolean Haarolean closed this as not planned Won't fix, can't repro, duplicate, stale Jun 30, 2023
@mhalbritter mhalbritter added status: invalid An issue that we don't feel is valid and removed status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged status: feedback-reminder We've sent a reminder that we need additional information before we can continue labels Jun 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

4 participants