{"record":{"id":"a2021d960dd299d5","repo":"apache/iceberg","slug":"cannot-load-dropwizard-metrics-is-org-apache-flin-a2021d","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.3/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.3/flink/src/main/java/org/apache/iceberg/flink/sink/IcebergStreamWriterMetrics.java#L132-L162","documentation":"A warning emitted when the Iceberg writer's Dropwizard-based histogram metrics cannot be initialized because the flink-metrics-dropwizard module (or its Codahale/Dropwizard metrics classes) is not on the classpath. Metrics are disabled (returns null) but the write itself continues normally.","triggerScenarios":"Running a Flink job whose IcebergStreamWriterMetrics tries to construct org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper via DynConstructors, throwing ClassNotFoundException/NoSuchMethodException because the flink-metrics-dropwizard jar is absent.","commonSituations":"Deploying to a slim Flink distribution without optional metrics plugins; fat jars that exclude optional dependencies; Flink versions where the Dropwizard wrapper package moved.","solutions":["Add org.apache.flink:flink-metrics-dropwizard to the job's classpath (drop it in Flink's lib/ or ship it with the user jar)","If metrics are not needed, ignore the warning — the writer works without the histogram","Check the Flink version's package location for DropwizardHistogramWrapper if the dependency is present but still failing"],"exampleFix":"// build.gradle\n// before: (no metrics dep)\n// after\nimplementation(\"org.apache.flink:flink-metrics-dropwizard:1.18.1\")","handlingStrategy":"fallback","validationCode":"try {\n  Class.forName(\"org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper\");\n} catch (ClassNotFoundException e) {\n  // dropwizard metrics unavailable; proceed without histograms\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ship flink-metrics-dropwizard with deployment artifacts","Verify optional metrics plugins in the base Flink image","Document that writer histograms are optional"],"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"}