{"record":{"id":"c4867e80fe3c693e","repo":"apache/iceberg","slug":"cannot-find-constructor-for-baseclass-formatp","errorCode":null,"errorMessage":"Cannot find constructor for ${baseClass}\n${formatProblems(problems)}","messagePattern":"Cannot find constructor for (.+?)\n(.+?)","errorType":"exception","errorClass":"NoSuchMethodException","httpStatus":null,"severity":"error","filePath":"common/src/main/java/org/apache/iceberg/common/DynConstructors.java","lineNumber":282,"sourceCode":"        problems.put(methodName(targetClass, types), e);\n      }\n      return this;\n    }\n\n    /**\n     * Returns the first valid constructor as a {@link Ctor} or throws a NoSuchMethodException if\n     * there is none.\n     *\n     * @param <C> Java class constructed by the constructor\n     * @return a {@link Ctor} with a valid implementation\n     * @throws NoSuchMethodException if no implementation was found\n     */\n    @SuppressWarnings(\"unchecked\")\n    public <C> Ctor<C> buildChecked() throws NoSuchMethodException {\n      if (ctor != null) {\n        return (Ctor<C>) ctor;\n      }\n      throw buildCheckedException(baseClass, problems);\n    }\n\n    /**\n     * Returns the first valid constructor as a {@link Ctor} or throws a RuntimeException if there\n     * is none.\n     *\n     * @param <C> Java class constructed by the constructor\n     * @return a {@link Ctor} with a valid implementation\n     * @throws RuntimeException if no implementation was found\n     */\n    @SuppressWarnings(\"unchecked\")\n    public <C> Ctor<C> build() {\n      if (ctor != null) {\n        return (Ctor<C>) ctor;\n      }\n      throw buildRuntimeException(baseClass, problems);\n    }\n","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/common/src/main/java/org/apache/iceberg/common/DynConstructors.java#L264-L300","documentation":"DynConstructors.Builder.buildChecked() searches for a constructor matching the classes/arguments added to the builder and returns it as a Ctor. If no matching constructor (or class) was found, it throws a NoSuchMethodException listing every candidate it tried and why it failed. The checked variant lets callers explicitly handle missing implementations.","triggerScenarios":"Calling buildChecked() when the target class name is wrong/misspelled, the class is not on the classpath, or no constructor matches the supplied parameter types (e.g. the catalog or file-io impl class was configured with a name whose constructor signature differs from the arguments passed).","commonSituations":"Typo in an impl property like org.apache.iceberg.aws.s3.S3FileIO; a jar is missing at runtime (shaded/not shipped); the implementation class was refactored and its constructor signature changed while config still points at the old one.","solutions":["Verify the configured class name is fully qualified and spelled correctly","Ensure the jar providing the class is on the runtime classpath","Check the class exposes a constructor matching the argument types passed to the builder","Call build() instead of buildChecked() if a RuntimeException with the same details is preferred"],"exampleFix":"// before\nCtor<FileIO> ctor = DynConstructors.builder().impl(\"com.example.MyFileIO\").buildChecked(); // NoSuchMethodException\n// after (verify class exists first)\nif (DynClasses.builder().impl(\"com.example.MyFileIO\").buildChecked() != null) {\n  Ctor<FileIO> ctor = DynConstructors.builder().impl(\"com.example.MyFileIO\").buildChecked();\n}","handlingStrategy":"try-catch","validationCode":"try { Class.forName(\"com.example.MyFileIO\", true, loader); } catch (ClassNotFoundException e) { /* fail fast with clear message */ }","typeGuard":null,"tryCatchPattern":"try { Ctor<C> ctor = builder.buildChecked(); } catch (NoSuchMethodException e) { throw new IllegalArgumentException(\"Bad impl config: \" + e.getMessage(), e); }","preventionTips":["Copy-paste fully qualified class names instead of typing them","Verify the impl jar ships with your distribution","Pin library versions so constructor signatures do not change unexpectedly"],"tags":["reflection","classpath","constructor","dynamic-loading"],"backgroundTag":"class-not-found","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}