apache/dubbo · error · IllegalStateException

Found invalid method config, the interface <interfaceClass.g

Error message

Found invalid method config, the interface <interfaceClass.getName()> not found method "<methodName>" : [<methodConfig>]

What it means

Thrown by AbstractInterfaceConfig.verifyMethodConfig: a MethodConfig names a method that does not exist on the interface (Arrays.stream(interfaceClass.getMethods()).noneMatch(...)), ignore-invalid-method-config is false, and isNeedCheckMethod() is true (non-generic call). Dubbo refuses to configure a method that the interface does not declare.

Source

Thrown at dubbo-common/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java:424

            } else {
                throw new IllegalStateException(msg);
            }
        }

        boolean hasMethod = Arrays.stream(interfaceClass.getMethods())
                .anyMatch(method -> method.getName().equals(methodName));
        if (!hasMethod) {
            String msg = "Found invalid method config, the interface " + interfaceClass.getName()
                    + " not found method \"" + methodName + "\" : [" + methodConfig + "]";
            if (ignoreInvalidMethodConfig) {
                logger.warn(CONFIG_NO_METHOD_FOUND, "", "", msg);
                return false;
            } else {
                if (!isNeedCheckMethod()) {
                    msg = "Generic call: " + msg;
                    logger.warn(CONFIG_NO_METHOD_FOUND, "", "", msg);
                } else {
                    throw new IllegalStateException(msg);
                }
            }
        }
        return true;
    }

    private ArgumentConfig getArgumentByIndex(MethodConfig methodConfig, int argIndex) {
        if (methodConfig.getArguments() != null && methodConfig.getArguments().size() > 0) {
            for (ArgumentConfig argument : methodConfig.getArguments()) {
                if (argument.getIndex() != null && argument.getIndex() == argIndex) {
                    return argument;
                }
            }
        }
        return null;
    }

    @Transient

View on GitHub (pinned to 3a3043227f)

Solutions

  1. Correct the method name in the config to exactly match a method declared on the interface.
  2. If the interface changed, update or remove the stale <dubbo:method> entry.
  3. Verify the interface class configured on the service/reference is the intended one.
  4. For generic invocation where unknown methods are expected, confirm isNeedCheckMethod() returns false (generic call) so it only warns.

Example fix

// before
<dubbo:service interface="com.acme.Greeting">
  <dubbo:method name="gretting" retries="3"/> <!-- typo -->
</dubbo:service>
// after
<dubbo:service interface="com.acme.Greeting">
  <dubbo:method name="greeting" retries="3"/>
</dubbo:service>
Defensive patterns

Strategy: validation

Validate before calling

void assertMethodExists(MethodConfig mc, Class<?> iface) {
    boolean ok = java.util.Arrays.stream(iface.getMethods())
        .anyMatch(m -> m.getName().equals(mc.getName()));
    if (!ok) throw new IllegalStateException(iface.getName() + " has no method " + mc.getName());
}

Type guard

boolean methodExistsOnInterface(String name, Class<?> iface) {
    return java.util.Arrays.stream(iface.getMethods()).anyMatch(m -> m.getName().equals(name));
}

Try / catch

try {
    serviceConfig.export();
} catch (IllegalStateException e) {
    if (e.getMessage().startsWith("Found invalid method config")) { /* correct/remove the method name */ }
    throw e;
}

Prevention

When it happens

Trigger: A <dubbo:method name="foo"> refers to 'foo' which is not declared on the service/reference interface. With generic calls (isNeedCheckMethod()==false) it degrades to a warning instead of throwing; otherwise it throws.

Common situations: Typo in the method name. The interface was refactored/renamed and the method config was not updated. Wrong interface class configured. Method name in config doesn't match due to overloaded/generic-erased signatures. Stale config after a service interface change.

Related errors


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