{"record":{"id":"6d76c3b5820f5872","repo":"alibaba/canal","slug":"extension-instance-name-name-class-type","errorCode":null,"errorMessage":"Extension instance(name: ${name}, class: ${type})  could not be instantiated: class could not be found","messagePattern":"Extension instance\\(name: (.+?), class: (.+?)\\)  could not be instantiated: class could not be found","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"connector/core/src/main/java/com/alibaba/otter/canal/connector/core/spi/ExtensionLoader.java","lineNumber":189,"sourceCode":"        }\n        try {\n            T instance = (T) EXTENSION_INSTANCES.get(clazz);\n            if (instance == null) {\n                EXTENSION_INSTANCES.putIfAbsent(clazz, (T) clazz.newInstance());\n                instance = (T) EXTENSION_INSTANCES.get(clazz);\n            }\n            return instance;\n        } catch (Throwable t) {\n            throw new IllegalStateException(\"Extension instance(name: \" + name + \", class: \" + type\n                                            + \")  could not be instantiated: \" + t.getMessage(), t);\n        }\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    private T createExtension(String name, String key, String spiDir, String standbyDir) {\n        Class<?> clazz = getExtensionClasses(spiDir, standbyDir).get(name);\n        if (clazz == null) {\n            throw new IllegalStateException(\"Extension instance(name: \" + name + \", class: \" + type\n                                            + \")  could not be instantiated: class could not be found\");\n        }\n        try {\n            T instance = (T) EXTENSION_KEY_INSTANCE.get(name + \"-\" + key);\n            if (instance == null) {\n                EXTENSION_KEY_INSTANCE.putIfAbsent(name + \"-\" + key, clazz.newInstance());\n                instance = (T) EXTENSION_KEY_INSTANCE.get(name + \"-\" + key);\n            }\n            return instance;\n        } catch (Throwable t) {\n            throw new IllegalStateException(\"Extension instance(name: \" + name + \", class: \" + type\n                                            + \")  could not be instantiated: \" + t.getMessage(), t);\n        }\n    }\n\n    private Map<String, Class<?>> getExtensionClasses(String spiDir, String standbyDir) {\n        Map<String, Class<?>> classes = cachedClasses.get();\n        if (classes == null) {","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/connector/core/src/main/java/com/alibaba/otter/canal/connector/core/spi/ExtensionLoader.java#L171-L207","documentation":"Thrown by the private 4-arg createExtension(name, key, spiDir, standbyDir) — the keyed-instance creation path — when the requested name is absent from the loaded extension class map. Same meaning as 209 but for per-key extension instances (extension name + key yields a dedicated instance stored under EXTENSION_KEY_INSTANCE).","triggerScenarios":"Keyed getExtension(name, key,...) where name has no SPI entry; the implementation jar is missing; the entry was rejected at load time (stored in exceptions map, surfacing later as 'could not be found').","commonSituations":"Per-destination producer loading where the producer mode (name) is misconfigured or its jar absent; SPI descriptor missing the name=impl mapping.","solutions":["Verify the extension name is registered in META-INF/canal/<interface> and the jar is present.","Check load-time logs/exceptions map for rejected entries (subtype/duplicate) that caused the name to be missing.","Correct the name property driving the keyed lookup."],"exampleFix":"// before\nloader.getExtension(\"rabitmq\", dest, spiDir, standbyDir);  // typo\n// after\nloader.getExtension(\"rabbitmq\", dest, spiDir, standbyDir);","handlingStrategy":"try-catch","validationCode":"// Pre-check name registration for keyed lookup\nif (!isRegistered(interfaceType, name)) {\n    throw new IllegalStateException(\n        \"keyed extension '\" + name + \"' not registered; verify plugin jar + descriptor\");\n}\nloader.getExtension(name, key, spiDir, standbyDir);","typeGuard":null,"tryCatchPattern":"try {\n    return loader.getExtension(name, key, spiDir, standbyDir);\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"could not be found\")) {\n        throw new IllegalStateException(\n            \"keyed extension '\" + name + \"' for key '\" + key + \"' missing\", e);\n    }\n    throw e;\n}","preventionTips":["Keep per-key extension descriptors consistent with single-key ones.","Check load-time logs for rejected entries that drop the name."],"tags":["spi","classpath","extension-loader","config"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}