How to troubleshoot Spring Boot app which fails during initialization
search cancel

How to troubleshoot Spring Boot app which fails during initialization

book

Article ID: 297134

calendar_today

Updated On:

Products

Support Only for Spring

Issue/Introduction

The Spring Boot app may fail to start during the initialization phase without errors. This is an example with the  Spring Boot app on Tanzu Application Service. The app fails to start and exits with status 1, which doesn't give many details regarding why it failed:
[APP/PROC/WEB/0] OUT   .   ____          _            __ _ _
[APP/PROC/WEB/0] OUT  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
[APP/PROC/WEB/0] OUT ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
[APP/PROC/WEB/0] OUT  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
[APP/PROC/WEB/0] OUT   '  |____| .__|_| |_|_| |_\__, | / / / /
[APP/PROC/WEB/0] OUT  =========|_|==============|___/=/_/_/_/
[APP/PROC/WEB/0] OUT  :: Spring Boot ::        (v2.3.3.RELEASE)
[APP/PROC/WEB/0] OUT Exit status 1
[CELL/SSHD/0] OUT Exit status 0
[CELL/0] OUT Cell e849a1cc-3962-4b20-965e-96661ccbef9b stopping instance b622c6a6-1c38-4b5c-5e42-ba53
[CELL/0] OUT Cell e849a1cc-3962-4b20-965e-96661ccbef9b destroying container for instance b622c6a6-1c38-4b5c-5e42-ba53
[API/1] OUT Process has crashed with type: "web"
[API/1] OUT App instance exited with guid 33a5c618-78d7-4d1a-bd64-89750f85cb56 payload: {"instance"=>"b622c6a6-1c38-4b5c-5e42-ba53", "index"=>0, "cell_id"=>"e849a1cc-3962-4b20-965e-96661ccbef9b", "reason"=>"CRASHED", "exit_description"=>"APP/PROC/WEB: Exited with status 1", "crash_count"=>1, "crash_timestamp"=>1620035569198894921, "version"=>"f9e1cca5-7f66-4040-9af7-7efcddb3372d"}


Resolution

To troubleshoot the problem:
 

1. Please enable debug level logs, this can be done in application profile. On Tanzu Application Service, please follow instructions the instructions in the following document:
 


2. If the app fails before the log level setting takes effect, please add a try-catch block in the main function and print out any caught exception. It helps if the case exception is not caught and ignored by the underlying framework. 

@SpringBootApplication
public class MyApplication {

   public static void main(String[] args) {
    try {
        SpringApplication.run(MyApplication.class, args);
    } catch (Throwable e) {
        e.printStackTrace(); 
    }
}