{"record":{"id":"5063560c5332445b","repo":"apache/dubbo","slug":"none-matched-constructor-was-found-for-type-typ","errorCode":null,"errorMessage":"None matched constructor was found for type: ${type}","messagePattern":"None matched constructor was found for type: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/common/beans/support/InstantiationStrategy.java","lineNumber":85,"sourceCode":"        if (defaultConstructor != null) {\n            matchedConstructors.remove(defaultConstructor);\n        }\n\n        // match order:\n        // 1. the only matched constructor with parameters\n        // 2. default constructor if absent\n\n        Constructor<?> targetConstructor;\n        if (matchedConstructors.size() > 1) {\n            throw new IllegalArgumentException(\"Expect only one but found \" + matchedConstructors.size()\n                    + \" matched constructors for type: \" + type.getName() + \", matched constructors: \"\n                    + matchedConstructors);\n        } else if (matchedConstructors.size() == 1) {\n            targetConstructor = matchedConstructors.get(0);\n        } else if (defaultConstructor != null) {\n            targetConstructor = defaultConstructor;\n        } else {\n            throw new IllegalArgumentException(\"None matched constructor was found for type: \" + type.getName());\n        }\n\n        // create instance with arguments\n        Class<?>[] parameterTypes = targetConstructor.getParameterTypes();\n        Object[] args = new Object[parameterTypes.length];\n        for (int i = 0; i < parameterTypes.length; i++) {\n            args[i] = getArgumentValueForType(parameterTypes[i]);\n        }\n        return (T) targetConstructor.newInstance(args);\n    }\n\n    private boolean isMatched(Constructor<?> constructor) {\n        for (Class<?> parameterType : constructor.getParameterTypes()) {\n            if (!isSupportedConstructorParameterType(parameterType)) {\n                return false;\n            }\n        }\n        return true;","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/common/beans/support/InstantiationStrategy.java#L67-L103","documentation":"Thrown by InstantiationStrategy.instantiate when the target class has neither a public no-arg constructor nor any public constructor whose parameters are all ScopeModel-subclass types. With no usable constructor, Dubbo cannot create the instance reflectively. IllegalArgumentException (wrapped by callers as ScopeBeanException).","triggerScenarios":"Instantiating an extension or registered bean whose only constructors require arbitrary (non-ScopeModel) arguments, a class with only private/protected constructors, an interface, or an abstract class. Also when a required dependency cannot be satisfied because the constructor signature is unsupported.","commonSituations":"SPI extension missing a public no-arg constructor; bean class refactored to require third-party dependencies in its constructor; class with only a builder/factory method; access restriction hiding the only constructor.","solutions":["Add a public no-arg constructor to the class so InstantiationStrategy can use it.","Or add a single public constructor whose parameters are all ScopeModel subclasses (ScopeModel/ApplicationModel/FrameworkModel/ModuleModel).","If construction needs custom dependencies, register a Supplier/instance via ScopeBeanFactory instead of relying on reflective instantiation.","Ensure the class is concrete and the constructor is public (not hidden by module/access rules)."],"exampleFix":"// before\npublic class MyExt {\n    private MyExt() {}            // inaccessible\n    MyExt(Config c) { ... }       // non-ScopeModel param\n}\n// after\npublic class MyExt {\n    public MyExt() { ... }        // usable default constructor\n}","handlingStrategy":"validation","validationCode":"// Verify a usable constructor exists before letting Dubbo instantiate\nboolean hasUsableConstructor(Class<?> c) {\n    if (c.isInterface() || Modifier.isAbstract(c.getModifiers())) return false;\n    try { c.getConstructor(); return true; } catch (NoSuchMethodException ignored) {}\n    for (Constructor<?> ctor : c.getConstructors()) {\n        boolean ok = true;\n        for (Class<?> p : ctor.getParameterTypes())\n            ok &= org.apache.dubbo.rpc.model.ScopeModel.class.isAssignableFrom(p);\n        if (ok) return true;\n    }\n    return false;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Give SPI extensions and registered beans a public no-arg constructor.","Or provide exactly one public constructor whose params are all ScopeModel subclasses.","Avoid requiring arbitrary constructor dependencies; use setters/Initializable instead.","When construction is non-trivial, register a Supplier or a pre-built instance."],"tags":["instantiation","constructor","reflection","dubbo-common"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}