Skip to content

Improve diagnostics when JVM launched by spring-boot:run exits with a non-zero status #16869

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
drahkrub opened this issue May 15, 2019 · 1 comment
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@drahkrub
Copy link

drahkrub commented May 15, 2019

If a forked spring boot app finishes with exitCode != 0 && exitCode != EXIT_CODE_SIGINT
a MojoExecutionException is thrown with the message "Application finished with exit code: " + exitCode.
This Exception is than catched by the surrounding try-catch and used as cause in a rethrown MojoExecutionException with the misleading/wrong message "Could not exec java".

So the initial thrown Exception is not "silently swallowed" but it is "hidden" as the root cause of the second Exception which exposes a misleading/wrong message.

This happened to me right when starting my spring boot app (had some problem in an ApplicationContextInitializer which was caused due to the problems described in #16819 - my app starts without problems in a non forked VM or when starting the JAR file), so my first thought was that something is wrong with my environment or java installation causing spring boot`s inability to "exec java" - took me quite some time.

Therefore optimizing the exception handling in this place (RunMojo#runWithForkedJvm(...)) would be nice (i.e. more specific error message in first place).

P.S.: Sorry for raising another issue but I'm afraid of creating more off-topic follow-up questions as in #16811 ;-)

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 15, 2019
@philwebb philwebb added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels May 15, 2019
@philwebb philwebb added this to the 2.2.x milestone May 15, 2019
@philwebb
Copy link
Member

I think it would be safe to change this catch to rethrow any MojoException without wrapping.

@wilkinsona wilkinsona changed the title spring-boot:run misleading/wrong message "Could not exec java" with a forked VM Improve diagnostics when JVM launched by spring-boot:run exits with a non-zero status May 17, 2019
@wilkinsona wilkinsona self-assigned this May 18, 2019
@wilkinsona wilkinsona modified the milestones: 2.2.x, 2.2.0.M4 May 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants