quarkusio/quarkus · error · java.lang.IllegalArgumentException

Cannot find method ${methodName}${parameterTypes} on ${clazz

Error message

Cannot find method ${methodName}${parameterTypes} on ${clazz}

What it means

Reflections.findMethod() walks the class and its interface hierarchy looking for a declared method with the given name and parameter types; if none is found it throws IllegalArgumentException with this message. It is used during reflective bean/interceptor setup, so it means declared reflective metadata doesn't match any real method.

Source

Thrown at independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/Reflections.java:115

                theClass = theClass.getSuperclass();
            }
        }
        //look for default methods on interfaces
        Set<Class<?>> seen = new HashSet<>(interfaces);
        while (!interfaces.isEmpty()) {
            Class<?> iface = interfaces.pop();
            try {
                return iface.getDeclaredMethod(methodName, parameterTypes);
            } catch (NoSuchMethodException ex) {
                //ignore
            }
            for (Class<?> extra : iface.getInterfaces()) {
                if (seen.add(extra)) {
                    interfaces.add(extra);
                }
            }
        }
        throw new IllegalArgumentException("Cannot find method " + methodName + Arrays.asList(parameterTypes) + " on " + clazz);
    }

    public static Constructor<?> findConstructor(Class<?> clazz, Class<?>... parameterTypes) {
        try {
            return clazz.getDeclaredConstructor(parameterTypes);
        } catch (NoSuchMethodException e) {
            throw new IllegalArgumentException(e);
        }
    }

    public static Object newInstance(Class<?> clazz, Class<?>[] parameterTypes, Object[] args) {
        Constructor<?> constructor = findConstructor(clazz, parameterTypes);
        if (constructor != null) {
            if (!constructor.canAccess(null)) {
                constructor.setAccessible(true);
            }
            try {
                return constructor.newInstance(args);

View on GitHub (pinned to e1c734241f)

Solutions

  1. Verify the exact method name and parameter types exist on the class (use javap or IDE) and correct the arguments.
  2. Account for inheritance: findMethod searches superclasses/interfaces — if the method is private on a supertype, locate it on the declaring class directly.
  3. After a dependency upgrade, regenerate any code or update reflective references to the new signature.
  4. Check boxed vs primitive parameter types (Integer.class vs int.class).

Example fix

// before
Reflections.findMethod(Foo.class, "process", String.class); // signature changed
// after
Reflections.findMethod(Foo.class, "process", String.class, Integer.class);
Defensive patterns

Strategy: validation

Validate before calling

static void requireMethod(Class<?> clazz, String name, Class<?>... params) {
    try { clazz.getDeclaredMethod(name, params); }
    catch (NoSuchMethodException e) {
        throw new IllegalStateException("Expected method " + name + Arrays.asList(params) + " on " + clazz, e);
    }
}

Type guard

boolean hasMethod(Class<?> c, String n, Class<?>... p) {
    try { c.getMethod(n, p); return true; } catch (NoSuchMethodException e) { return false; }
}

Try / catch

try {
    Method m = Reflections.findMethod(clazz, name, paramTypes);
    return m.invoke(target, args);
} catch (IllegalArgumentException e) {
    throw new IllegalStateException("Reflective signature out of sync with " + clazz.getName() + " — update after upgrades", e);
}

Prevention

When it happens

Trigger: Calling Reflections.findMethod(clazz, name, paramTypes...) where the method was renamed, removed, or has a different signature (added/changed parameters, primitives vs wrappers, varargs differences).

Common situations: Upgrading a library whose method signature changed while reflective references (generated code, config in strings) still use the old one; typos in method names; passing wrong parameter type list (boxed Integer vs int).

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/c1956e8e21d0d45f. Report an issue: GitHub.