{"record":{"id":"a6c3768427eb2ca9","repo":"risingwavelabs/risingwave","slug":"fail-to-new-jvm","errorCode":null,"errorMessage":"fail to new JVM","messagePattern":"fail to new JVM","errorType":"exception","errorClass":"anyhow","httpStatus":null,"severity":"critical","filePath":"src/jni_core/src/jvm_runtime.rs","lineNumber":123,"sourceCode":"    // Exit the embedded JVM on uncaught `OutOfMemoryError` so that the host\n    // compute node process terminates and the cluster recovers via the standard\n    // recovery loop, matching native OOM behavior. Set `JVM_EXIT_ON_OOM=false`\n    // (or `0`) to opt out.\n    let exit_on_oom = std::env::var(\"JVM_EXIT_ON_OOM\")\n        .map(|v| !matches!(v.to_ascii_lowercase().as_str(), \"false\" | \"0\" | \"\"))\n        .unwrap_or(true);\n    if exit_on_oom {\n        args_builder = args_builder.option(\"-XX:+ExitOnOutOfMemoryError\");\n    }\n\n    tracing::info!(\"JVM args: {:?}\", args_builder);\n    let jvm_args = args_builder.build().context(\"invalid jvm args\")?;\n\n    // Create a new VM\n    let jvm = match JavaVM::new(jvm_args) {\n        Err(err) => {\n            tracing::error!(error = ?err.as_report(), \"fail to new JVM\");\n            bail!(\"fail to new JVM\");\n        }\n        Ok(jvm) => jvm,\n    };\n\n    tracing::info!(\"initialize JVM successfully\");\n\n    let result: std::result::Result<(), jni::errors::Error> = try {\n        let mut env = jvm_env(&jvm)?;\n        register_java_binding_native_methods(&mut env)?;\n    };\n\n    result.context(\"failed to register native method\")?;\n\n    Ok(jvm)\n}\n\npub fn jvm_env(jvm: &JavaVM) -> Result<AttachGuard<'_>, jni::errors::Error> {\n    jvm.attach_current_thread()","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/jni_core/src/jvm_runtime.rs#L105-L141","documentation":"JavaVM::new failed to create the Java virtual machine after the JNI args (classpath, options, etc.) were built. The detailed JNI error is logged, and a generic `fail to new JVM` error is returned. Common causes are a missing/incompatible libjvm, wrong JAVA_HOME, bad JVM options, or insufficient memory.","triggerScenarios":"Calling build_jvm_with_native_registration when libjvm.so cannot be found/loaded, an invalid JVM option string is passed via JNI args, or the JDK version is incompatible with the expected one (e.g. Java 11 vs 17).","commonSituations":"JAVA_HOME unset or pointing at a JRE instead of a JDK, CONNECTOR_LIBS_PATH containing an incompatible JDK, missing libjvm.so on the loader path (LD_LIBRARY_PATH), containers without a JVM installed.","solutions":["Check the error log line `fail to new JVM` for the underlying JNI error code.","Verify JAVA_HOME points to a full JDK (e.g. Java 11/17 as required) with lib/.../libjvm.so present.","Set LD_LIBRARY_PATH to include $JAVA_HOME/lib/server so libjvm.so loads.","Review CONNECTOR_LIBS_PATH/jvm options for invalid -X flags or garbage values.","Confirm enough memory exists (JVM heap options not exceeding container limits)."],"exampleFix":"// before\n# no JAVA_HOME, only a JRE installed\n// after\nexport JAVA_HOME=/usr/lib/jvm/java-17-openjdk && export LD_LIBRARY_PATH=$JAVA_HOME/lib/server:$LD_LIBRARY_PATH","handlingStrategy":"try-catch","validationCode":"test -n \"$JAVA_HOME\" && test -f \"$JAVA_HOME/lib/server/libjvm.so\" && echo 'JVM OK' || echo 'JAVA_HOME missing or libjvm.so not found'","typeGuard":null,"tryCatchPattern":"match jvm_runtime::global_jvm() {\n    Err(e) if e.to_string().contains(\"fail to new JVM\") => {\n        // check JAVA_HOME, LD_LIBRARY_PATH, JDK version, then surface a clear ops message\n    }\n    other => other?,\n}","preventionTips":["Pin the required JDK version in the deployment image and CI.","Export JAVA_HOME and include $JAVA_HOME/lib/server in LD_LIBRARY_PATH.","Validate JVM -X options against container memory limits.","Smoke-test JVM startup in a preflight step before launching the connector."],"tags":["jvm","jni","configuration","startup"],"backgroundTag":"module-init-failed","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}