{"record":{"id":"ab6d6cd2c7ce0b2d","repo":"apache/iceberg","slug":"cannot-load-dropwizard-metrics-is-org-apache-flin-ab6d6c","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.2/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.2/flink/src/main/java/org/apache/iceberg/flink/sink/IcebergStreamWriterMetrics.java#L132-L162","documentation":"IcebergStreamWriterMetrics uses reflection (DynConstructors) to load Flink's Dropwizard metric wrappers. When org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper (from flink-metrics-dropwizard) is not on the classpath, construction fails with ClassNotFoundException/NoSuchMethodException and this warning is logged; writer metrics are simply not registered.","triggerScenarios":"Creating an IcebergStreamWriter instance (which wires up writer metrics) in a deployment where the flink-metrics-dropwizard jar is absent from the Flink lib/plugins classpath.","commonSituations":"Minimal Flink distributions (e.g. some Kubernetes/Kinesis-analytics setups) that exclude optional metrics jars; moving a job from a full Flink distro to a slim container image.","solutions":["Add org.apache.flink:flink-metrics-dropwizard jar to FLINK_HOME/lib (or the job classpath).","If metrics are not needed, ignore the warning — the sink still functions.","For containerized deployments, bake the jar into the image or mount it via the Flink plugins directory."],"exampleFix":"// build.gradle\n// before\nimplementation 'org.apache.flink:flink-streaming-java'\n// after\nimplementation 'org.apache.flink:flink-streaming-java'\nimplementation 'org.apache.flink:flink-metrics-dropwizard'","handlingStrategy":"fallback","validationCode":"// check classpath before enabling writer metrics\nClass.forName(\"org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper\");","typeGuard":null,"tryCatchPattern":"try { Class.forName(\"org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper\"); } catch (ClassNotFoundException e) { LOG.info(\"Dropwizard metrics unavailable; writer metrics disabled\"); }","preventionTips":["Ship flink-metrics-dropwizard in FLINK_HOME/lib for all deployments","Bake the metrics jar into custom Flink container images","Treat the warning as benign if metrics are not required"],"tags":["flink","metrics","classpath","optional-dependency"],"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"}