apache/iceberg · warning
Cannot load Dropwizard metrics; is…
Error message
Cannot load Dropwizard metrics; is org.apache.flink:flink-metrics-dropwizard on the classpath?
What it means
IcebergStreamWriterMetrics optionally exposes Dropwizard histograms for write latency. It loads org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper reflectively; when flink-metrics-dropwizard is not on the classpath the class can't be loaded, the metrics are disabled with this warning, and the writer continues without them.
Solutions
- Add org.apache.flink:flink-metrics-dropwizard (matching your Flink version) to the job jar or Flink lib/ directory.
- Ignore the warning if the Dropwriter-based latency metrics are not needed — functionality is unaffected.
- Verify the dependency isn't lost by shading exclusions (check the shaded uber-jar contents).
Example fix
// Maven: before (missing)
<!-- no flink-metrics-dropwizard -->
// after
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-metrics-dropwizard</artifactId>
<version>${flink.version}</version>
</dependency> Defensive patterns
Strategy: fallback
Validate before calling
try {
Class.forName("org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper");
} catch (ClassNotFoundException e) {
LOG.warn("flink-metrics-dropwizard missing; latency histograms disabled");
} Try / catch
// Warning is non-fatal; if you need metrics, verify the jar at deploy time
try {
Class.forName("org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper");
} catch (ClassNotFoundException e) {
throw new IllegalStateException("Add flink-metrics-dropwizard to the classpath", e);
} Prevention
- Bundle flink-metrics-dropwizard in the job jar or Flink lib/.
- Match its version to your Flink version.
- Check shaded uber-jar for excluded optional dependencies.
When it happens
Trigger: Running a Flink job with the Iceberg stream writer where the flink-metrics-dropwizard jar is absent from the job's classpath (lib/, uber-jar, or user code loader).
Common situations: Deploying the Iceberg Flink runtime jar standalone without the metrics reporter dependency; using a minimal Flink distribution; shading the job and excluding optional dependencies.
Understand the failure class
Background: "X is not installed. Please install it with pip install Y": missing optional dependency errors — ImportError/ValueError raised when a library's optional extra was never installed — this error's family across 22 libraries.
Related errors
- Cannot load Dropwizard metrics; is…
- Cannot load Dropwizard metrics; is…
- Cannot load Dropwizard metrics; is…
- Class does not implement DynamicRecordGeneratorSQL
- Could not deserialize the WriteResult object
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/a9106cfa07e83798.
Report an issue: GitHub.
Appendix: source
Thrown at flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/sink/IcebergStreamWriterMetrics.java:150
try {
Class<?> reservoirInterface =
DynClasses.builder().impl("com.codahale.metrics.Reservoir").buildChecked();
Class<?> codahaleHistogramClass =
DynClasses.builder().impl("com.codahale.metrics.Histogram").buildChecked();
return new DropwizardCtors(
DynConstructors.builder()
.impl("com.codahale.metrics.SlidingWindowReservoir", int.class)
.buildChecked(),
DynConstructors.builder()
.impl("com.codahale.metrics.Histogram", reservoirInterface)
.buildChecked(),
DynConstructors.builder(Histogram.class)
.impl(
"org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper",
codahaleHistogramClass)
.buildChecked());
} catch (ClassNotFoundException | NoSuchMethodException e) {
LOG.warn(
"Cannot load Dropwizard metrics; is org.apache.flink:flink-metrics-dropwizard on the classpath?",
e);
return null;
}
}
private record DropwizardCtors(
DynConstructors.Ctor<?> reservoirCtor,
DynConstructors.Ctor<?> histogramCtor,
DynConstructors.Ctor<Histogram> wrapperCtor) {}
}
View on GitHub (pinned to 86d9c8fc54)