{"record":{"id":"d66ae27dc0f55482","repo":"openjdk/jdk","slug":"server-failed-to-initialize","errorCode":null,"errorMessage":"Server failed to initialize: {}","messagePattern":"Server failed to initialize: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"make/langtools/tools/javacserver/client/Client.java","lineNumber":188,"sourceCode":"            // Throws an IOException if no valid values materialize\n            conf.portFile().waitForValidValues();\n        } catch (IOException ex) {\n            // Process was started, but server failed to initialize. This could\n            // for instance be due to the JVM not finding the server class,\n            // or the server running in to some exception early on.\n            Log.error(\"javacserver server process failed to initialize: \" + ex.getMessage());\n            Log.error(\"Process output:\");\n            Reader serverStdoutStderr = new InputStreamReader(serverProcess.getInputStream());\n            try (BufferedReader br = new BufferedReader(serverStdoutStderr)) {\n                br.lines().forEach(Log::error);\n            }\n            Log.error(\"<End of process output>\");\n            try {\n                Log.error(\"Process exit code: \" + serverProcess.exitValue());\n            } catch (IllegalThreadStateException e) {\n                // Server is presumably still running.\n            }\n            throw new IOException(\"Server failed to initialize: \" + ex.getMessage(), ex);\n        }\n    }\n}\n","sourceCodeStart":170,"sourceCodeEnd":192,"githubUrl":"https://github.com/openjdk/jdk/blob/88dfb74bbeefcf2b0aa11835183bcd949998fc8f/make/langtools/tools/javacserver/client/Client.java#L170-L192","documentation":"IOException from Client.startNewServer(): the client forked a javacserver daemon process, but it failed to initialize (the awaited readiness signal threw), so the client logs the daemon's entire stdout/stderr and its exit code, then rethrows with the original exception as cause. The daemon's output printed just before this exception is the primary diagnostic.","triggerScenarios":"The spawned server JVM exits or hangs during startup — incompatible JVM options, port file creation failure (permissions on the port file directory), or a classpath problem in the forked command.","commonSituations":"java.home changed after a JDK upgrade so the fork command is stale; the /tmp or build dir used for the port file is not writable; memory limits (ulimit/cgroups) preventing the second JVM from starting.","solutions":["Read the 'Process output:' block in the log — it contains the daemon's actual startup error.","Check the 'Process exit code' line: non-zero exit usually means JVM options/classpath issues; missing exit code means it hung.","Verify the port file directory is writable and not full.","Remove stale port files and leftover server processes, then retry so a clean daemon is forked."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// pre-flight the forked JVM command before relying on the server\nString javaBin = Paths.get(System.getProperty(\"java.home\"), \"bin\", \"java\").toString();\nProcessBuilder check = new ProcessBuilder(javaBin, \"-version\").redirectErrorStream(true);\nif (check.start().waitFor() != 0)\n    throw new IOException(\"cannot start a JVM for javacserver: \" + javaBin);","typeGuard":null,"tryCatchPattern":"try {\n    client.startNewServer();\n} catch (IOException e) {\n    // message already contains the daemon's stdout/stderr; fall back to in-process javac\n    Log.error(\"javacserver unavailable, falling back to local javac\", e);\n    runLocalJavac(args); // graceful degradation instead of failing the build\n}","preventionTips":["Validate that the build JVM can fork (memory limits, exec permissions) before enabling the server.","Keep the port-file directory writable and on a local filesystem.","Capture daemon output (the client already logs it) in CI artifacts for post-mortem."],"tags":["javacserver","process","startup","build","diagnostics"],"backgroundTag":null,"analyzedSha":"88dfb74bbeefcf2b0aa11835183bcd949998fc8f","analyzedAt":"2026-08-14T11:45:09.665Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}