{"record":{"id":"dbe08279f2017639","repo":"apache/iceberg","slug":"cannot-initialize-aliyunclientfactory-s-does-not","errorCode":null,"errorMessage":"Cannot initialize AliyunClientFactory, %s does not implement AliyunClientFactory.","messagePattern":"Cannot initialize AliyunClientFactory, (.+?) does not implement AliyunClientFactory\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"aliyun/src/main/java/org/apache/iceberg/aliyun/AliyunClientFactories.java","lineNumber":79,"sourceCode":"   * @return an initialized {@link AliyunClientFactory}.\n   */\n  private static AliyunClientFactory loadClientFactory(\n      String impl, Map<String, String> properties) {\n    DynConstructors.Ctor<AliyunClientFactory> ctor;\n    try {\n      ctor = DynConstructors.builder(AliyunClientFactory.class).hiddenImpl(impl).buildChecked();\n    } catch (NoSuchMethodException e) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"Cannot initialize AliyunClientFactory, missing no-arg constructor: %s\", impl),\n          e);\n    }\n\n    AliyunClientFactory factory;\n    try {\n      factory = ctor.newInstance();\n    } catch (ClassCastException e) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"Cannot initialize AliyunClientFactory, %s does not implement AliyunClientFactory.\",\n              impl),\n          e);\n    }\n\n    factory.initialize(properties);\n    return factory;\n  }\n\n  static class DefaultAliyunClientFactory implements AliyunClientFactory {\n    private static final Logger LOG = LoggerFactory.getLogger(DefaultAliyunClientFactory.class);\n    private AliyunProperties aliyunProperties;\n\n    DefaultAliyunClientFactory() {}\n\n    /**\n     * Check if RRSA environment variables are present. RRSA requires","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/aliyun/src/main/java/org/apache/iceberg/aliyun/AliyunClientFactories.java#L61-L97","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Make the configured class implement org.apache.iceberg.aliyun.AliyunClientFactory.","Check for duplicate/conflicting jars on the classpath (old version of your factory jar shadowing a newer one).","Confirm the fully-qualified class name points at the factory, not at a client or properties class."],"exampleFix":"// before\npublic class MyOSSHelper { }\n\n// after\npublic class MyOSSHelper implements AliyunClientFactory {\n  public MyOSSHelper() {}\n  // implement interface methods\n}","handlingStrategy":"type-guard","validationCode":"Class<?> c = Class.forName(implClassName);\nif (!AliyunClientFactory.class.isAssignableFrom(c)) {\n  throw new IllegalStateException(implClassName + \" does not implement AliyunClientFactory\");\n}","typeGuard":"if (obj instanceof AliyunClientFactory) { AliyunClientFactory f = (AliyunClientFactory) obj; }","tryCatchPattern":null,"preventionTips":["Verify the configured class implements AliyunClientFactory before wiring it into properties.","Check classpath for duplicate/stale jars of your factory.","Add a startup smoke test that instantiates the factory by name."],"tags":["reflection","type-mismatch","aliyun"],"backgroundTag":"type-mismatch","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}