{"record":{"id":"50dc2ecae5b71f82","repo":"apache/iceberg","slug":"cannot-load-dropwizard-metrics-is-org-apache-flin-50dc2e","errorCode":null,"errorMessage":"Cannot load Dropwizard metrics; is org.apache.flink:flink-metrics-dropwizard on the classpath?","messagePattern":"Cannot load Dropwizard metrics; is org\\.apache\\.flink:flink-metrics-dropwizard on the classpath\\?","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/sink/IcebergStreamWriterMetrics.java","lineNumber":150,"sourceCode":"    try {\n      Class<?> reservoirInterface =\n          DynClasses.builder().impl(\"com.codahale.metrics.Reservoir\").buildChecked();\n      Class<?> codahaleHistogramClass =\n          DynClasses.builder().impl(\"com.codahale.metrics.Histogram\").buildChecked();\n      return new DropwizardCtors(\n          DynConstructors.builder()\n              .impl(\"com.codahale.metrics.SlidingWindowReservoir\", int.class)\n              .buildChecked(),\n          DynConstructors.builder()\n              .impl(\"com.codahale.metrics.Histogram\", reservoirInterface)\n              .buildChecked(),\n          DynConstructors.builder(Histogram.class)\n              .impl(\n                  \"org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper\",\n                  codahaleHistogramClass)\n              .buildChecked());\n    } catch (ClassNotFoundException | NoSuchMethodException e) {\n      LOG.warn(\n          \"Cannot load Dropwizard metrics; is org.apache.flink:flink-metrics-dropwizard on the classpath?\",\n          e);\n      return null;\n    }\n  }\n\n  private record DropwizardCtors(\n      DynConstructors.Ctor<?> reservoirCtor,\n      DynConstructors.Ctor<?> histogramCtor,\n      DynConstructors.Ctor<Histogram> wrapperCtor) {}\n}\n","sourceCodeStart":132,"sourceCodeEnd":162,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/sink/IcebergStreamWriterMetrics.java#L132-L162","documentation":"Iceberg's Flink sink tries to construct Flink's DropwizardHistogramWrapper to expose codahale histograms as Flink metrics. This requires the optional org.apache.flink:flink-metrics-dropwizard artifact on the classpath. When the class or constructor cannot be loaded, the sink logs this warning and returns null, disabling Dropwizard-based writer metrics; writes continue normally without them.","triggerScenarios":"IcebergStreamWriterMetrics.loadDropwizardCtors runs DynConstructors.builder(Histogram.class).impl(\"org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper\", codahaleHistogramClass).buildChecked() and catches ClassNotFoundException/NoSuchMethodException when flink-metrics-dropwizard is absent or its version is incompatible with the codahale Histogram class.","commonSituations":"Deploying the Iceberg Flink sink JAR without the metrics connector JAR in Flink's lib/ directory; using a shaded/uber job jar that excludes optional Flink metrics dependencies; Flink distribution upgrades where metrics-dropwizard was not carried over.","solutions":["Add the flink-metrics-dropwizard JAR matching your Flink version to Flink's lib/ directory (or shade it into your job jar).","Verify the org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper class is loadable in the taskmanager classloader.","If metrics are not needed, ignore this warning; the sink falls back to null and runs without Dropwizard histograms."],"exampleFix":"// before (pom.xml: optional metric dependency omitted)\n<dependency>\n  <groupId>org.apache.iceberg</groupId>\n  <artifactId>iceberg-flink-runtime-1.20</artifactId>\n</dependency>\n\n// after\n<dependency>\n  <groupId>org.apache.iceberg</groupId>\n  <artifactId>iceberg-flink-runtime-1.20</artifactId>\n</dependency>\n<dependency>\n  <groupId>org.apache.flink</groupId>\n  <artifactId>flink-metrics-dropwizard</artifactId>\n  <version>${flink.version}</version>\n</dependency>","handlingStrategy":"validation","validationCode":"try {\n  Class.forName(\"org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper\");\n} catch (ClassNotFoundException e) {\n  LOG.info(\"flink-metrics-dropwizard not on classpath; writer histograms disabled\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ship flink-metrics-dropwizard with your Flink deployment (lib/) in every environment.","Keep optional metric dependency versions aligned with the Flink version.","Treat this warning as expected-and-harmless if Dropwizard metrics are intentionally disabled."],"tags":["flink","metrics","classpath","dropwizard"],"backgroundTag":"missing-optional-dependency","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}