{"record":{"id":"b36b8b491de8eca0","repo":"apache/beam","slug":"error-at-jvminitializer-beforeprocessing-this-error-is","errorCode":null,"errorMessage":"Error at JvmInitializer#beforeProcessing. This error is suppressed after previous success runs. It is expected on Embedded environment","messagePattern":"Error at JvmInitializer#beforeProcessing\\. This error is suppressed after previous success runs\\. It is expected on Embedded environment","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/fn/JvmInitializers.java","lineNumber":66,"sourceCode":"   * initialization but before beginning to process any data.\n   *\n   * @param options The pipeline options passed to the worker.\n   */\n  public static void runBeforeProcessing(PipelineOptions options) {\n    // We load the logger in the method to minimize the amount of class loading that happens\n    // during class initialization.\n    Logger logger = LoggerFactory.getLogger(JvmInitializers.class);\n\n    try {\n      for (JvmInitializer initializer : ReflectHelpers.loadServicesOrdered(JvmInitializer.class)) {\n        logger.info(\"Running JvmInitializer#beforeProcessing for {}\", initializer);\n        initializer.beforeProcessing(options);\n        logger.info(\"Completed JvmInitializer#beforeProcessing for {}\", initializer);\n      }\n      initialized.compareAndSet(false, true);\n    } catch (Error e) {\n      if (initialized.get()) {\n        logger.warn(\n            \"Error at JvmInitializer#beforeProcessing. This error is suppressed after \"\n                + \"previous success runs. It is expected on Embedded environment\",\n            e);\n      } else {\n        throw e;\n      }\n    }\n  }\n}\n","sourceCodeStart":48,"sourceCodeEnd":76,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/fn/JvmInitializers.java#L48-L76","documentation":"JvmInitializers.runBeforeProcessing invokes each registered JvmInitializer's beforeProcessing hook. If an Error is thrown after a previous run already completed initialization (initialized flag set), it is logged as a warning and suppressed, since this is expected in embedded FnHarness environments that re-run initialization. On the first run the Error is rethrown.","triggerScenarios":"A JvmInitializer.beforeProcessing throws an Error (e.g. OOM LinkageError, custom initializer failure) during a re-invocation of runBeforeProcessing after a previously successful run, typically in embedded runner environments.","commonSituations":"Embedded FnHarness executing the same initializer twice; JVM startup hooks that are not idempotent; memory or classpath errors surfacing on the second pass.","solutions":["Make your JvmInitializer.beforeProcessing idempotent so a second invocation does not throw.","Read the logged warning stack trace to identify which initializer failed and why.","If the Error occurs on the first run it is fatal — fix the initializer's resource/classpath problem.","Avoid registering initializers that assume single execution in embedded environments."],"exampleFix":"// before\npublic void beforeProcessing(PipelineOptions options) { connect(options); } // throws on reconnect\n// after\nprivate volatile boolean done;\npublic void beforeProcessing(PipelineOptions options) { if (!done) { connect(options); done = true; } }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  JvmInitializers.runBeforeProcessing(options);\n} catch (Throwable t) {\n  // On embedded runners a second pass may throw after a prior success; log and continue.\n  LOG.warn(\"JvmInitializer beforeProcessing failed (may be benign in embedded mode)\", t);\n}","preventionTips":["Write idempotent JvmInitializer.beforeProcessing implementations.","Guard connections/clients with idempotency flags in initializers.","Check the logged stack trace to identify the offending initializer before assuming it is benign."],"tags":["jvm","initialization","beam","embedded-runner"],"backgroundTag":"module-init-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}