{"record":{"id":"c9e739b9507dfee1","repo":"apache/iceberg","slug":"cannot-initialize-keymanagementclient-missing-no","errorCode":null,"errorMessage":"Cannot initialize KeyManagementClient, missing no-arg constructor for class ${kmsImpl}","messagePattern":"Cannot initialize KeyManagementClient, missing no-arg constructor for class (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/encryption/EncryptionUtil.java","lineNumber":79,"sourceCode":"                CatalogProperties.ENCRYPTION_KMS_IMPL_AWS;\n            case CatalogProperties.ENCRYPTION_KMS_TYPE_AZURE ->\n                CatalogProperties.ENCRYPTION_KMS_IMPL_AZURE;\n            case CatalogProperties.ENCRYPTION_KMS_TYPE_GCP ->\n                CatalogProperties.ENCRYPTION_KMS_IMPL_GCP;\n            default -> throw new IllegalStateException(\"Unsupported KMS type: \" + kmsType);\n          };\n    }\n\n    KeyManagementClient kmsClient;\n    DynConstructors.Ctor<KeyManagementClient> ctor;\n    try {\n      ctor =\n          DynConstructors.builder(KeyManagementClient.class)\n              .loader(EncryptionUtil.class.getClassLoader())\n              .impl(kmsImpl)\n              .buildChecked();\n    } catch (NoSuchMethodException e) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"Cannot initialize KeyManagementClient, missing no-arg constructor for class %s\",\n              kmsImpl),\n          e);\n    }\n\n    try {\n      kmsClient = ctor.newInstance();\n    } catch (ClassCastException e) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"Cannot initialize kms client, %s does not implement KeyManagementClient interface\",\n              kmsImpl),\n          e);\n    }\n\n    kmsClient.initialize(catalogProperties);\n","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/encryption/EncryptionUtil.java#L61-L97","documentation":"EncryptionUtil.createKmsClient loads the configured encryption.kms.impl class reflectively via DynConstructors, requiring a public no-arg constructor implementing KeyManagementClient. If no such constructor exists (NoSuchMethodException), it throws IllegalArgumentException naming the class.","triggerScenarios":"Setting encryption.kms.impl to a class that has only parameterized constructors, is abstract, or implements the wrong interface so no matching no-arg impl ctor resolves.","commonSituations":"Custom KMS client implementations that require config in the constructor; pointing kms.impl at a factory/wrapper class instead of the client itself; class compiled against a different KeyManagementClient interface version.","solutions":["Add a public no-arg constructor to the configured KeyManagementClient class","Configure the class so it reads its settings from catalog/table properties at construction time instead of constructor args","Point encryption.kms.impl at the concrete client class, not a factory or abstract class","Verify the class implements org.apache.iceberg.encryption.KeyManagementClient and is on the classpath"],"exampleFix":"// before\nclass MyKmsClient implements KeyManagementClient {\n  MyKmsClient(String keyId) { ... }\n}\n// after\nclass MyKmsClient implements KeyManagementClient {\n  public MyKmsClient() { this.keyId = System.getenv(\"KMS_KEY_ID\"); }\n  MyKmsClient(String keyId) { ... }\n}","handlingStrategy":"validation","validationCode":"Class<?> c = Class.forName(kmsImpl);\nif (!KeyManagementClient.class.isAssignableFrom(c)) {\n  throw new IllegalArgumentException(kmsImpl + \" does not implement KeyManagementClient\");\n}\nif (java.lang.reflect.Modifier.isAbstract(c.getModifiers()) ||\n    c.getConstructors().length == 0 ||\n    java.util.Arrays.stream(c.getConstructors()).noneMatch(ctor -> ctor.getParameterCount() == 0)) {\n  throw new IllegalArgumentException(kmsImpl + \" lacks a public no-arg constructor\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  kms = EncryptionUtil.createKmsClient(config);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"missing no-arg constructor\")) {\n    throw new ConfigException(\"encryption.kms.impl class must be public, concrete, and have a no-arg ctor\", e);\n  }\n  throw e;\n}","preventionTips":["Implement custom KMS clients with a public no-arg constructor reading config from properties","Point kms.impl at the concrete client class, never a factory or abstract base","Add a startup smoke test that instantiates the configured class reflectively","Ensure the class is compiled against the same Iceberg KeyManagementClient interface version"],"tags":["reflection","encryption","kms","configuration"],"backgroundTag":"invalid-constructor-argument","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"}