apache/beam · error · IllegalArgumentException

NoOpMetricsSink was not found on classpath

Error message

NoOpMetricsSink was not found on classpath

What it means

MetricsOptions.AllowedMetricsSinkValidator.create attempts to load org.apache.beam.runners.core.metrics.NoOpMetricsSink reflectively. When that class is not on the classpath it throws IllegalArgumentException, because the default sink used to discard metrics is unavailable.

Source

Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/MetricsOptions.java:54

   * exists on the classpath, and throws an exception otherwise.
   *
   * <p>As the {@code NoOpMetricsSink} is in an independent module, it cannot be directly referenced
   * as the {@link Default}. However, it should still be used if available.
   */
  class NoOpMetricsSink implements DefaultValueFactory<Class<? extends MetricsSink>> {
    @Override
    public Class<? extends MetricsSink> create(PipelineOptions options) {
      try {
        @SuppressWarnings({"unchecked", "rawtypes"})
        Class<? extends MetricsSink> noOpMetricsSinkClass =
            (Class<? extends MetricsSink>)
                Class.forName(
                    "org.apache.beam.runners.core.metrics.NoOpMetricsSink",
                    true,
                    ReflectHelpers.findClassLoader());
        return noOpMetricsSinkClass;
      } catch (ClassNotFoundException e) {
        throw new IllegalArgumentException(
            String.format("NoOpMetricsSink was not found on classpath"));
      }
    }
  }

  @Description("The metrics push period in seconds")
  @Default.Long(5)
  Long getMetricsPushPeriod();

  void setMetricsPushPeriod(Long period);

  @Description("MetricsHttpSink url")
  String getMetricsHttpSinkUrl();

  void setMetricsHttpSinkUrl(String metricsSink);

  @Description("The graphite metrics host")
  String getMetricsGraphiteHost();

View on GitHub (pinned to 12126d8942)

Solutions

  1. Add beam-runners-core-java to the runtime classpath.
  2. Check that shading/relocation doesn't rename or drop org.apache.beam.runners.core.metrics.NoOpMetricsSink.
  3. Configure a valid metricsSink option matching an actually available sink class.
  4. Align all Beam artifact versions so the class exists in the resolved dependency set.

Example fix

// before (build.gradle)
implementation 'org.apache.beam:beam-sdks-java-core'
// after
implementation 'org.apache.beam:beam-sdks-java-core'
implementation 'org.apache.beam:beam-runners-core-java'
Defensive patterns

Strategy: validation

Validate before calling

try { Class.forName("org.apache.beam.runners.core.metrics.NoOpMetricsSink", false, Thread.currentThread().getContextClassLoader()); } catch (ClassNotFoundException e) { addBeamRunnersCore(); }

Try / catch

try { opts = PipelineOptionsFactory.create(); } catch (IllegalArgumentException e) { LOG.error("classpath missing metrics sink: " + e.getMessage()); throw e; }

Prevention

When it happens

Trigger: Running with a Beam deploy classpath missing the runners-core module (where NoOpMetricsSink lives) — e.g. a slimmed-down shaded jar, or explicitly setting metricsSink with an invalid value that resolves the no-op default.

Common situations: Fat-jar/shading configurations that exclude org.apache.beam:beam-runners-core-java, custom dependency trees for embedded Beam usage, or version upgrades where the class moved packages.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/0a0a2cb208955bb5. Report an issue: GitHub.