apache/dubbo · error · IllegalArgumentException

None matched constructor was found for type: ${type}

Error message

None matched constructor was found for type: ${type}

What it means

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).

Source

Thrown at dubbo-common/src/main/java/org/apache/dubbo/common/beans/support/InstantiationStrategy.java:85

        if (defaultConstructor != null) {
            matchedConstructors.remove(defaultConstructor);
        }

        // match order:
        // 1. the only matched constructor with parameters
        // 2. default constructor if absent

        Constructor<?> targetConstructor;
        if (matchedConstructors.size() > 1) {
            throw new IllegalArgumentException("Expect only one but found " + matchedConstructors.size()
                    + " matched constructors for type: " + type.getName() + ", matched constructors: "
                    + matchedConstructors);
        } else if (matchedConstructors.size() == 1) {
            targetConstructor = matchedConstructors.get(0);
        } else if (defaultConstructor != null) {
            targetConstructor = defaultConstructor;
        } else {
            throw new IllegalArgumentException("None matched constructor was found for type: " + type.getName());
        }

        // create instance with arguments
        Class<?>[] parameterTypes = targetConstructor.getParameterTypes();
        Object[] args = new Object[parameterTypes.length];
        for (int i = 0; i < parameterTypes.length; i++) {
            args[i] = getArgumentValueForType(parameterTypes[i]);
        }
        return (T) targetConstructor.newInstance(args);
    }

    private boolean isMatched(Constructor<?> constructor) {
        for (Class<?> parameterType : constructor.getParameterTypes()) {
            if (!isSupportedConstructorParameterType(parameterType)) {
                return false;
            }
        }
        return true;

View on GitHub (pinned to 3a3043227f)

Solutions

  1. Add a public no-arg constructor to the class so InstantiationStrategy can use it.
  2. Or add a single public constructor whose parameters are all ScopeModel subclasses (ScopeModel/ApplicationModel/FrameworkModel/ModuleModel).
  3. If construction needs custom dependencies, register a Supplier/instance via ScopeBeanFactory instead of relying on reflective instantiation.
  4. Ensure the class is concrete and the constructor is public (not hidden by module/access rules).

Example fix

// before
public class MyExt {
    private MyExt() {}            // inaccessible
    MyExt(Config c) { ... }       // non-ScopeModel param
}
// after
public class MyExt {
    public MyExt() { ... }        // usable default constructor
}
Defensive patterns

Strategy: validation

Validate before calling

// Verify a usable constructor exists before letting Dubbo instantiate
boolean hasUsableConstructor(Class<?> c) {
    if (c.isInterface() || Modifier.isAbstract(c.getModifiers())) return false;
    try { c.getConstructor(); return true; } catch (NoSuchMethodException ignored) {}
    for (Constructor<?> ctor : c.getConstructors()) {
        boolean ok = true;
        for (Class<?> p : ctor.getParameterTypes())
            ok &= org.apache.dubbo.rpc.model.ScopeModel.class.isAssignableFrom(p);
        if (ok) return true;
    }
    return false;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14). Data as JSON: /api/errors/5063560c5332445b. Report an issue: GitHub.