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

Spring Boot shudown fails with an error #1799

Closed
rgoers opened this issue Sep 18, 2023 · 1 comment
Closed

Spring Boot shudown fails with an error #1799

rgoers opened this issue Sep 18, 2023 · 1 comment
Assignees
Labels
bug Incorrect, unexpected, or unintended behavior of existing code

Comments

@rgoers
Copy link
Member

rgoers commented Sep 18, 2023

Description

This issue is captured in spring-projects/spring-boot#33450. During shutdown properties are being accessed, which causes the Spring Property Source to be invoked. However, it needs an active LoggerContext to work.

Configuration

Version: 2.20.0

Logs

[Stacktraces, errors, etc. relevant applications logs.]

Reproduction

While building a sample Spring Boot app I ran into a similar, but related, error.

WARN StatusConsoleListener Unable to register Log4j shutdown hook because JVM is shutting down. Using SimpleLogger
Exception in thread "SpringApplicationShutdownHook" java.lang.ClassCastException: class org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to class org.apache.logging.log4j.core.LoggerContext (org.apache.logging.log4j.simple.SimpleLoggerContext and org.apache.logging.log4j.core.LoggerContext are in unnamed module of loader org.springframework.boot.loader.LaunchedURLClassLoader @5b480cf9)
at org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.getLoggerContext(Log4J2LoggingSystem.java:480)
at org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.lambda$getShutdownHandler$2(Log4J2LoggingSystem.java:452)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.boot.SpringApplicationShutdownHook.run(SpringApplicationShutdownHook.java:110)
at java.base/java.lang.Thread.run(Thread.java:833)

We have seen this in other cases but have never come up with a permanent solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect, unexpected, or unintended behavior of existing code
Projects
None yet
Development

No branches or pull requests

2 participants