alibaba/arthas · error · IllegalStateException

AllServerStart must be initialized before!

Error message

AllServerStart must be initialized before!

What it means

DemoBootstrap.getRunningInstance() throws IllegalStateException when called before the singleton has been initialized via getInstance(). The class is a lazy-initialized server bootstrap: getInstance() creates and starts all servers; getRunningInstance() assumes they are already running. Calling getRunningInstance() first skips initialization and has no server to return.

Source

Thrown at labs/arthas-grpc-web-proxy/src/main/java/com/taobao/arthas/grpcweb/grpc/DemoBootstrap.java:141

        String currentDir = new File(getClass().getProtectionDomain().getCodeSource().getLocation().getPath()).getParentFile().getPath();
        String STATIC_LOCATION = Paths.get(currentDir, "static").toString();
        NettyHttpServer nettyHttpServer = new NettyHttpServer(HTTP_PORT,STATIC_LOCATION);
        logger.info("start grpc server on port: {}, grpc web proxy server on port: {}, " +
                "http server server on port: {}", GRPC_PORT,GRPC_WEB_PROXY_PORT,HTTP_PORT);
        System.out.println("Open your web browser and navigate to " + "http" + "://127.0.0.1:" + HTTP_PORT + '/' + "index.html");
        nettyHttpServer.start();
    }

    public synchronized static DemoBootstrap getInstance() throws Throwable {
        if (demoBootstrap == null) {
            demoBootstrap = new DemoBootstrap();
        }
        return demoBootstrap;
    }

    public static DemoBootstrap getRunningInstance() {
        if (demoBootstrap == null) {
            throw new IllegalStateException("AllServerStart must be initialized before!");
        }
        return demoBootstrap;
    }

    public void execute(Runnable command) {
        executorService.execute(command);
    }



    public static void appendSpyJar(Instrumentation instrumentation) throws IOException {
        // find spy target/classes directory
        String file = DemoBootstrap.class.getProtectionDomain().getCodeSource().getLocation().getFile();

        File spyClassDir = new File(file, "../../../spy/target/classes").getAbsoluteFile();

        File destJarFile = new File(file, "../../../spy/target/test-spy.jar").getAbsoluteFile();

View on GitHub (pinned to 21cf2e9ba5)

Solutions

  1. Call DemoBootstrap.getInstance() (which initializes and starts servers) before any call to getRunningInstance().
  2. Review startup ordering to ensure the bootstrap is created early in the lifecycle.
  3. If the bootstrap may or may not be started, check with a null-guarding helper or catch IllegalStateException and initialize on demand.

Example fix

// before
DemoBootstrap bootstrap = DemoBootstrap.getRunningInstance(); // throws

// after
DemoBootstrap bootstrap = DemoBootstrap.getInstance(); // initializes if needed
// later, only after init:
DemoBootstrap running = DemoBootstrap.getRunningInstance();
Defensive patterns

Strategy: validation

Validate before calling

// Initialize before accessing the running instance
DemoBootstrap bootstrap;
try {
    bootstrap = DemoBootstrap.getRunningInstance();
} catch (IllegalStateException e) {
    bootstrap = DemoBootstrap.getInstance(); // triggers initialization
}

Try / catch

try {
    return DemoBootstrap.getRunningInstance();
} catch (IllegalStateException e) {
    if (e.getMessage().contains("initialized before")) {
        return DemoBootstrap.getInstance();
    }
    throw e;
}

Prevention

When it happens

Trigger: Invoking DemoBootstrap.getRunningInstance() without a prior successful DemoBootstrap.getInstance() call in the same JVM.

Common situations: Startup ordering bug — a component that needs the running bootstrap is initialized before the bootstrap itself; a test or CLI entry point calls getRunningInstance() directly; refactoring moved the getInstance() call behind a condition that evaluated false.

Related errors


AI-assisted analysis of alibaba/arthas@21cf2e9ba5 (2026-08-14). Data as JSON: /api/errors/709d76348c259aef. Report an issue: GitHub.