{"record":{"id":"0a0a2cb208955bb5","repo":"apache/beam","slug":"noopmetricssink-was-not-found-on-classpath","errorCode":null,"errorMessage":"NoOpMetricsSink was not found on classpath","messagePattern":"NoOpMetricsSink was not found on classpath","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/MetricsOptions.java","lineNumber":54,"sourceCode":"   * exists on the classpath, and throws an exception otherwise.\n   *\n   * <p>As the {@code NoOpMetricsSink} is in an independent module, it cannot be directly referenced\n   * as the {@link Default}. However, it should still be used if available.\n   */\n  class NoOpMetricsSink implements DefaultValueFactory<Class<? extends MetricsSink>> {\n    @Override\n    public Class<? extends MetricsSink> create(PipelineOptions options) {\n      try {\n        @SuppressWarnings({\"unchecked\", \"rawtypes\"})\n        Class<? extends MetricsSink> noOpMetricsSinkClass =\n            (Class<? extends MetricsSink>)\n                Class.forName(\n                    \"org.apache.beam.runners.core.metrics.NoOpMetricsSink\",\n                    true,\n                    ReflectHelpers.findClassLoader());\n        return noOpMetricsSinkClass;\n      } catch (ClassNotFoundException e) {\n        throw new IllegalArgumentException(\n            String.format(\"NoOpMetricsSink was not found on classpath\"));\n      }\n    }\n  }\n\n  @Description(\"The metrics push period in seconds\")\n  @Default.Long(5)\n  Long getMetricsPushPeriod();\n\n  void setMetricsPushPeriod(Long period);\n\n  @Description(\"MetricsHttpSink url\")\n  String getMetricsHttpSinkUrl();\n\n  void setMetricsHttpSinkUrl(String metricsSink);\n\n  @Description(\"The graphite metrics host\")\n  String getMetricsGraphiteHost();","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/MetricsOptions.java#L36-L72","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add beam-runners-core-java to the runtime classpath.","Check that shading/relocation doesn't rename or drop org.apache.beam.runners.core.metrics.NoOpMetricsSink.","Configure a valid metricsSink option matching an actually available sink class.","Align all Beam artifact versions so the class exists in the resolved dependency set."],"exampleFix":"// before (build.gradle)\nimplementation 'org.apache.beam:beam-sdks-java-core'\n// after\nimplementation 'org.apache.beam:beam-sdks-java-core'\nimplementation 'org.apache.beam:beam-runners-core-java'","handlingStrategy":"validation","validationCode":"try { Class.forName(\"org.apache.beam.runners.core.metrics.NoOpMetricsSink\", false, Thread.currentThread().getContextClassLoader()); } catch (ClassNotFoundException e) { addBeamRunnersCore(); }","typeGuard":null,"tryCatchPattern":"try { opts = PipelineOptionsFactory.create(); } catch (IllegalArgumentException e) { LOG.error(\"classpath missing metrics sink: \" + e.getMessage()); throw e; }","preventionTips":["Include beam-runners-core-java in runtime dependencies","Verify shaded jars keep/relocate NoOpMetricsSink correctly","Keep all Beam artifact versions aligned"],"tags":["apache-beam","classpath","metrics"],"backgroundTag":"class-not-found","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}