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 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.

Solutions

  1. Add org.apache.flink:flink-metrics-dropwizard jar to FLINK_HOME/lib (or the job classpath).
  2. If metrics are not needed, ignore the warning — the sink still functions.
  3. For containerized deployments, bake the jar into the image or mount it via the Flink plugins directory.

Example fix

// build.gradle
// before
implementation 'org.apache.flink:flink-streaming-java'
// after
implementation 'org.apache.flink:flink-streaming-java'
implementation 'org.apache.flink:flink-metrics-dropwizard'
Defensive patterns

Strategy: fallback

Validate before calling

// check classpath before enabling writer metrics
Class.forName("org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper");

Try / catch

try { Class.forName("org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper"); } catch (ClassNotFoundException e) { LOG.info("Dropwizard metrics unavailable; writer metrics disabled"); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

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


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/ab6d6cd2c7ce0b2d. Report an issue: GitHub.

Appendix: source

Thrown at flink/v2.2/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)