apache/iceberg · error · IllegalArgumentException

Cannot initialize AliyunClientFactory, %s does not implement

Error message

Cannot initialize AliyunClientFactory, %s does not implement AliyunClientFactory.

What it means

After reflectively instantiating the configured factory class, loadClientFactory casts the result to AliyunClientFactory. If the created object does not implement that interface, the ClassCastException is rethrown as this IllegalArgumentException. The configured class simply is not the right type.

Source

Thrown at aliyun/src/main/java/org/apache/iceberg/aliyun/AliyunClientFactories.java:79

   * @return an initialized {@link AliyunClientFactory}.
   */
  private static AliyunClientFactory loadClientFactory(
      String impl, Map<String, String> properties) {
    DynConstructors.Ctor<AliyunClientFactory> ctor;
    try {
      ctor = DynConstructors.builder(AliyunClientFactory.class).hiddenImpl(impl).buildChecked();
    } catch (NoSuchMethodException e) {
      throw new IllegalArgumentException(
          String.format(
              "Cannot initialize AliyunClientFactory, missing no-arg constructor: %s", impl),
          e);
    }

    AliyunClientFactory factory;
    try {
      factory = ctor.newInstance();
    } catch (ClassCastException e) {
      throw new IllegalArgumentException(
          String.format(
              "Cannot initialize AliyunClientFactory, %s does not implement AliyunClientFactory.",
              impl),
          e);
    }

    factory.initialize(properties);
    return factory;
  }

  static class DefaultAliyunClientFactory implements AliyunClientFactory {
    private static final Logger LOG = LoggerFactory.getLogger(DefaultAliyunClientFactory.class);
    private AliyunProperties aliyunProperties;

    DefaultAliyunClientFactory() {}

    /**
     * Check if RRSA environment variables are present. RRSA requires

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Make the configured class implement org.apache.iceberg.aliyun.AliyunClientFactory.
  2. Check for duplicate/conflicting jars on the classpath (old version of your factory jar shadowing a newer one).
  3. Confirm the fully-qualified class name points at the factory, not at a client or properties class.

Example fix

// before
public class MyOSSHelper { }

// after
public class MyOSSHelper implements AliyunClientFactory {
  public MyOSSHelper() {}
  // implement interface methods
}
Defensive patterns

Strategy: type-guard

Validate before calling

Class<?> c = Class.forName(implClassName);
if (!AliyunClientFactory.class.isAssignableFrom(c)) {
  throw new IllegalStateException(implClassName + " does not implement AliyunClientFactory");
}

Type guard

if (obj instanceof AliyunClientFactory) { AliyunClientFactory f = (AliyunClientFactory) obj; }

Prevention

When it happens

Trigger: Setting the factory impl property to a class that exists and has a no-arg constructor but does not implement org.apache.iceberg.aliyun.AliyunClientFactory (e.g. an OSS client, a different vendor's factory, or a stale class).

Common situations: Copy-pasting a factory class name from a different catalog implementation (Hadoop/S3/Aliyun mixups); a refactor renamed/moved the interface so an old jar still has the pre-interface class; shading changed the package.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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