pinpoint-apm/pinpoint · error · RuntimeException

${methodName} not found

Error message

${methodName} not found

What it means

RuntimeException("<methodName> not found") thrown by InterceptorDefinitionFactory.findMethodByName when scanning the interceptor's declared methods for one named "before" or "after" and none matches. This runs after the 2-method check, so it means the declared methods exist but neither carries the expected name.

Source

Thrown at agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/interceptor/InterceptorDefinitionFactory.java:142

        final String after = "after";
        final Method afterMethod = findMethodByName(declaredMethods, after);
        final Class<?>[] afterParamList = afterMethod.getParameterTypes();

        return new TypeHandler(interceptorClazz, interceptorType, before, beforeParamList, after, afterParamList);
    }


    private Method findMethodByName(Method[] declaredMethods, String methodName) {
        Method findMethod = null;
        int count = 0;
        for (Method method : declaredMethods) {
            if (method.getName().equals(methodName)) {
                count++;
                findMethod = method;
            }
        }
        if (findMethod == null) {
            throw new RuntimeException(methodName + " not found");
        }
        if (count > 1 ) {
            throw new RuntimeException("duplicated method exist. methodName:" + methodName);
        }
        return findMethod;
    }


    private class TypeHandler {
        private final Class<? extends Interceptor> interceptorClazz;
        private final InterceptorType interceptorType;
        private final String before;
        private final Class<?>[] beforeParamList;
        private final String after;
        private final Class<?>[] afterParamList;

        public TypeHandler(Class<? extends Interceptor> interceptorClazz, InterceptorType interceptorType, String before, final Class<?>[] beforeParamList, final String after, final Class<?>[] afterParamList) {
            this.interceptorClazz = Objects.requireNonNull(interceptorClazz, "interceptorClazz");

View on GitHub (pinned to 744c3d3075)

Solutions

  1. Rename your methods to exactly before and after.
  2. Confirm the class actually declares (not just inherits) both methods, since only getDeclaredMethods() is scanned.
  3. Check the enclosing Interceptor interface's required method names for your Pinpoint version.

Example fix

// before
class MyInterceptor implements Interceptor {
    public void doBefore(Object t, Object[] a) { }
    public void doAfter(Object t, Object r, Throwable th) { }
}
// after
class MyInterceptor implements Interceptor {
    public void before(Object t, Object[] a) { }
    public void after(Object t, Object r, Throwable th) { }
}
Defensive patterns

Strategy: validation

Validate before calling

boolean hasBefore = Arrays.stream(clazz.getDeclaredMethods()).anyMatch(m -> m.getName().equals("before"));
boolean hasAfter  = Arrays.stream(clazz.getDeclaredMethods()).anyMatch(m -> m.getName().equals("after"));
if (!hasBefore || !hasAfter) throw new IllegalArgumentException(clazz + " must declare both before() and after()");

Try / catch

try { factory.createInterceptorDefinition(clazz); } catch (RuntimeException e) { if (e.getMessage().endsWith("not found")) { /* rename methods to before/after */ } throw e; }

Prevention

When it happens

Trigger: createInterceptorTypeHandler resolves declaredMethods and findMethodByName(declaredMethods, "before") or ("after") finds no method with that exact name - e.g. methods named differently (pre/post, doBefore) or an interface with default-named methods mismatch.

Common situations: Renaming before/after in a custom interceptor implementation, implementing Interceptor with a different naming convention, or an IDE auto-generating method stubs with different names.

Related errors


AI-assisted analysis of pinpoint-apm/pinpoint@744c3d3075 (2026-09-07). Data as JSON: /api/errors/6e796c66beeda80f. Report an issue: GitHub.