{"record":{"id":"6e796c66beeda80f","repo":"pinpoint-apm/pinpoint","slug":"methodname-not-found","errorCode":null,"errorMessage":"${methodName} not found","messagePattern":"(.+?) not found","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/interceptor/InterceptorDefinitionFactory.java","lineNumber":142,"sourceCode":"        final String after = \"after\";\n        final Method afterMethod = findMethodByName(declaredMethods, after);\n        final Class<?>[] afterParamList = afterMethod.getParameterTypes();\n\n        return new TypeHandler(interceptorClazz, interceptorType, before, beforeParamList, after, afterParamList);\n    }\n\n\n    private Method findMethodByName(Method[] declaredMethods, String methodName) {\n        Method findMethod = null;\n        int count = 0;\n        for (Method method : declaredMethods) {\n            if (method.getName().equals(methodName)) {\n                count++;\n                findMethod = method;\n            }\n        }\n        if (findMethod == null) {\n            throw new RuntimeException(methodName + \" not found\");\n        }\n        if (count > 1 ) {\n            throw new RuntimeException(\"duplicated method exist. methodName:\" + methodName);\n        }\n        return findMethod;\n    }\n\n\n    private class TypeHandler {\n        private final Class<? extends Interceptor> interceptorClazz;\n        private final InterceptorType interceptorType;\n        private final String before;\n        private final Class<?>[] beforeParamList;\n        private final String after;\n        private final Class<?>[] afterParamList;\n\n        public TypeHandler(Class<? extends Interceptor> interceptorClazz, InterceptorType interceptorType, String before, final Class<?>[] beforeParamList, final String after, final Class<?>[] afterParamList) {\n            this.interceptorClazz = Objects.requireNonNull(interceptorClazz, \"interceptorClazz\");","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/interceptor/InterceptorDefinitionFactory.java#L124-L160","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Rename your methods to exactly before and after.","Confirm the class actually declares (not just inherits) both methods, since only getDeclaredMethods() is scanned.","Check the enclosing Interceptor interface's required method names for your Pinpoint version."],"exampleFix":"// before\nclass MyInterceptor implements Interceptor {\n    public void doBefore(Object t, Object[] a) { }\n    public void doAfter(Object t, Object r, Throwable th) { }\n}\n// after\nclass MyInterceptor implements Interceptor {\n    public void before(Object t, Object[] a) { }\n    public void after(Object t, Object r, Throwable th) { }\n}","handlingStrategy":"validation","validationCode":"boolean hasBefore = Arrays.stream(clazz.getDeclaredMethods()).anyMatch(m -> m.getName().equals(\"before\"));\nboolean hasAfter  = Arrays.stream(clazz.getDeclaredMethods()).anyMatch(m -> m.getName().equals(\"after\"));\nif (!hasBefore || !hasAfter) throw new IllegalArgumentException(clazz + \" must declare both before() and after()\");","typeGuard":null,"tryCatchPattern":"try { factory.createInterceptorDefinition(clazz); } catch (RuntimeException e) { if (e.getMessage().endsWith(\"not found\")) { /* rename methods to before/after */ } throw e; }","preventionTips":["Use the exact names before and after","Declare both methods in the concrete class (inherited methods are not scanned)","Follow an official interceptor example verbatim when starting"],"tags":["interceptor","reflection","pinpoint","missing-method"],"backgroundTag":"method-not-implemented","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}