{"record":{"id":"25fe081ca1b7db5a","repo":"karatelabs/karate","slug":"boot-ext-name-failed-to-construct-classname-e-getmessage","errorCode":null,"errorMessage":"boot.ext('${name}'): failed to construct ${className} — ${e.getMessage()}","messagePattern":"boot\\.ext\\('(.+?)'\\): failed to construct (.+?) — (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/core/BootBinding.java","lineNumber":237,"sourceCode":"            }\n        }\n        String className = extClassName(name);\n        Ext ext;\n        try {\n            Class<?> cls = Class.forName(className);\n            Object instance = cls.getDeclaredConstructor().newInstance();\n            if (!(instance instanceof Ext)) {\n                throw new RuntimeException(\n                        \"boot.ext('\" + name + \"'): \" + className\n                                + \" does not implement io.karatelabs.core.Ext\");\n            }\n            ext = (Ext) instance;\n        } catch (ClassNotFoundException e) {\n            throw new RuntimeException(\n                    \"boot.ext('\" + name + \"'): not on classpath. Expected \"\n                            + className + \" (name-convention resolution).\", e);\n        } catch (Exception e) {\n            throw new RuntimeException(\n                    \"boot.ext('\" + name + \"'): failed to construct \" + className\n                            + \" — \" + e.getMessage(), e);\n        }\n        // Fire onBoot eagerly per K43. Throws here fail the Suite.\n        ext.onBoot(suite);\n        exts.add(ext);\n        registrar.accept(ext);\n        logger.info(\"ext booted: {} ({})\", name, ext.getClass().getName());\n        return ext;\n    }\n\n    /**\n     * {@code boot.has('name')} — is this ext available to boot? A pure classpath probe using the same\n     * name convention as {@link #ext(String)}; constructs nothing and registers nothing.\n     *\n     * <p>Exists because {@code boot.ext} is deliberately strict — a typo, or a missing ext the project\n     * genuinely depends on, must fail the suite loudly. But a project may legitimately depend on an ext\n     * <i>only when it is present</i>: a kit whose gRPC/Kafka beat is optional still has to run on a","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/BootBinding.java#L219-L255","documentation":"boot.ext(name) found and loaded the Ext class but instantiating it (via getDeclaredConstructor().newInstance()) failed — for reasons other than the class being missing — such as a missing no-arg constructor, a constructor that threw, or security/reflective access failure. The RuntimeException wraps the cause and reports the original message.","triggerScenarios":"The resolved Ext class has no accessible no-arg constructor; the constructor throws an exception during initialization (e.g. it reads config files or connects to services at construction time and fails); InstantiationException for abstract classes; IllegalAccessException for non-public classes.","commonSituations":"Extension written with a required-argument constructor; constructor performing eager I/O that fails in CI environments; class declared abstract by mistake; extension class not public.","solutions":["Give the Ext class a public no-argument constructor and move initialization work into onBoot(suite) instead of the constructor.","Make the class public and non-abstract.","Read the wrapped cause (e.getMessage() in the message) and fix whatever the constructor is doing that throws.","Guard constructor-time environment dependencies so construction succeeds in any environment."],"exampleFix":"// before\npublic class MyExt implements Ext {\n    public MyExt(String configPath) { ... } // no no-arg ctor\n}\n// after\npublic class MyExt implements Ext {\n    public MyExt() { }\n    public void onBoot(Suite suite) { /* init here */ }\n}","handlingStrategy":"try-catch","validationCode":"// verify the Ext class can be constructed before boot\nExt.class.cast(cls.getDeclaredConstructor().newInstance()); // mirrors library behavior","typeGuard":null,"tryCatchPattern":"try {\n    boot.ext(name);\n} catch (RuntimeException e) {\n    Throwable cause = e.getCause();\n    // cause reveals constructor failure: missing no-arg ctor, thrown init exception, access flags\n}","preventionTips":["Always give Ext implementations a public no-argument constructor.","Do heavy initialization in onBoot(suite), not the constructor.","Make constructor code environment-safe (no eager I/O or network at construction).","Keep the class public and non-abstract."],"tags":["boot","extension","reflection","instantiation"],"backgroundTag":"module-init-failed","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-16T19:17:19.609Z"}