Skip to content

Spring Shell Application Exits Immediately Without Starting Interactive Mode #1313

@gchape

Description

@gchape

Description

Spring Shell application completes startup successfully but exits immediately instead of entering interactive mode. The application context starts, all beans are created, and the application reaches ACCEPTING_TRAFFIC readiness state, but then the shutdown hook is triggered immediately.

Configuration

application.yml

spring:
  application:
    name: mudis
    version: 0.0.1
  profiles:
    active: dev
  shell:
    interactive:
      enabled: true
    command:
      script:
        enabled: false
    context:
      close: false
  main:
    banner-mode: console
  banner:
    location: banner.txt

mudis:
  server:
    port: 8888
    host: localhost

Main Application Class

package io.mudis.mudis;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication(
        proxyBeanMethods = false,
        scanBasePackages = {
                "io.mudis.mudis.client",
                "io.mudis.mudis.server",
                "io.mudis.mudis.command",
        })
public class MudisCLI {

    static void main(String... args) {
        SpringApplication.run(MudisCLI.class, args);
    }
}

Relevant Log Sections

Successful Startup

2026-02-04T16:58:39.723+04:00  INFO 42718 --- [mudis] [           main] io.mudis.mudis.MudisCLI                  : Started MudisCLI in 1.642 seconds (process running for 2.027)
2026-02-04T16:58:39.726+04:00 DEBUG 42718 --- [mudis] [           main] o.s.b.a.ApplicationAvailabilityBean      : Application availability state LivenessState changed to CORRECT
2026-02-04T16:58:39.730+04:00 DEBUG 42718 --- [mudis] [           main] o.s.b.a.ApplicationAvailabilityBean      : Application availability state ReadinessState changed to ACCEPTING_TRAFFIC

Immediate Shutdown

2026-02-04T16:58:39.732+04:00 DEBUG 42718 --- [mudis] [ionShutdownHook] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@74589991, started on Wed Feb 04 16:58:38 GMT+04:00 2026

Conditional Matches (Shell Configuration)

ShellRunnerAutoConfiguration#systemShellRunner matched:
   - @ConditionalOnMissingClass did not find unwanted class 'org.springframework.shell.jline.DefaultJLineShellConfiguration' (OnClassCondition)
   - @ConditionalOnProperty (spring.shell.interactive.enabled=true) matched (OnPropertyCondition)

ShellRunnerAutoConfiguration#springShellApplicationRunner matched:
   - @ConditionalOnMissingBean (types: org.springframework.boot.ApplicationRunner; SearchStrategy: all) did not find any beans (OnBeanCondition)

Expected Behavior

The application should:

  1. Complete startup
  2. Display the Spring Shell prompt
  3. Wait for user input in interactive mode
  4. Remain running until the user exits

Actual Behavior

The application:

  1. Completes startup successfully
  2. Immediately triggers the shutdown hook
  3. Exits with code 0 without entering interactive mode

Additional Context

The logs show that:

  • spring.shell.interactive.enabled=true is properly configured
  • systemShellRunner bean is created successfully
  • springShellApplicationRunner bean is created successfully
  • consoleInputProvider bean is created successfully
  • All auto-configuration conditions match correctly

However, there's a warning about Netty's sun.misc.Unsafe being unavailable on Java 25, though this appears to be handled gracefully:

2026-02-04T16:58:39.313+04:00 DEBUG 42718 --- [mudis] [           main] i.n.util.internal.PlatformDependent0     : sun.misc.Unsafe: unavailable (io.netty.noUnsafe=true by default on Java 25+)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions