apache/beam · warning
Error at JvmInitializer#beforeProcessing. This error is…
Error message
Error at JvmInitializer#beforeProcessing. This error is suppressed after previous success runs. It is expected on Embedded environment
What it means
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.
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.
Example fix
// before
public void beforeProcessing(PipelineOptions options) { connect(options); } // throws on reconnect
// after
private volatile boolean done;
public void beforeProcessing(PipelineOptions options) { if (!done) { connect(options); done = true; } } Defensive patterns
Strategy: try-catch
Try / catch
try {
JvmInitializers.runBeforeProcessing(options);
} catch (Throwable t) {
// On embedded runners a second pass may throw after a prior success; log and continue.
LOG.warn("JvmInitializer beforeProcessing failed (may be benign in embedded mode)", t);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Embedded FnHarness executing the same initializer twice; JVM startup hooks that are not idempotent; memory or classpath errors surfacing on the second pass.
Related errors
- error in starting expansion service, StartService()
- Spark Receiver was not initialized
- A dataSourceConfiguration or dataSourceProviderFn has…
- A list of URNs for overriding transforms was provided but…
- A cannot be expanded
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/b36b8b491de8eca0.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/fn/JvmInitializers.java:66
* initialization but before beginning to process any data.
*
* @param options The pipeline options passed to the worker.
*/
public static void runBeforeProcessing(PipelineOptions options) {
// We load the logger in the method to minimize the amount of class loading that happens
// during class initialization.
Logger logger = LoggerFactory.getLogger(JvmInitializers.class);
try {
for (JvmInitializer initializer : ReflectHelpers.loadServicesOrdered(JvmInitializer.class)) {
logger.info("Running JvmInitializer#beforeProcessing for {}", initializer);
initializer.beforeProcessing(options);
logger.info("Completed JvmInitializer#beforeProcessing for {}", initializer);
}
initialized.compareAndSet(false, true);
} catch (Error e) {
if (initialized.get()) {
logger.warn(
"Error at JvmInitializer#beforeProcessing. This error is suppressed after "
+ "previous success runs. It is expected on Embedded environment",
e);
} else {
throw e;
}
}
}
}
View on GitHub (pinned to 12126d8942)