{"record":{"id":"ee4d26924de24e62","repo":"mybatis/mybatis-3","slug":"could-not-find-method-on-named-cause","errorCode":null,"errorMessage":"Could not find method on {} named {}. Cause: {}","messagePattern":"Could not find method on (.+?) named (.+?)\\. Cause: (.+?)","errorType":"exception","errorClass":"PluginException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/apache/ibatis/plugin/Plugin.java","lineNumber":81,"sourceCode":"    }\n  }\n\n  private static Map<Class<?>, Set<Method>> getSignatureMap(Interceptor interceptor) {\n    Intercepts interceptsAnnotation = interceptor.getClass().getAnnotation(Intercepts.class);\n    // issue #251\n    if (interceptsAnnotation == null) {\n      throw new PluginException(\n          \"No @Intercepts annotation was found in interceptor \" + interceptor.getClass().getName());\n    }\n    Signature[] sigs = interceptsAnnotation.value();\n    Map<Class<?>, Set<Method>> signatureMap = new HashMap<>();\n    for (Signature sig : sigs) {\n      Set<Method> methods = signatureMap.computeIfAbsent(sig.type(), k -> new HashSet<>());\n      try {\n        Method method = sig.type().getMethod(sig.method(), sig.args());\n        methods.add(method);\n      } catch (NoSuchMethodException e) {\n        throw new PluginException(\"Could not find method on \" + sig.type() + \" named \" + sig.method() + \". Cause: \" + e,\n            e);\n      }\n    }\n    return signatureMap;\n  }\n\n  private static Class<?>[] getAllInterfaces(Class<?> type, Map<Class<?>, Set<Method>> signatureMap) {\n    Set<Class<?>> interfaces = new HashSet<>();\n    while (type != null) {\n      for (Class<?> c : type.getInterfaces()) {\n        if (signatureMap.containsKey(c)) {\n          interfaces.add(c);\n        }\n      }\n      type = type.getSuperclass();\n    }\n    return interfaces.toArray(new Class<?>[0]);\n  }","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/mybatis/mybatis-3/blob/008069adb1b089579b5dcba87ee591908b263274/src/main/java/org/apache/ibatis/plugin/Plugin.java#L63-L99","documentation":"Plugin.getSignatureMap() resolves each @Signature with Class.getMethod(name, args) and throws PluginException when lookup fails. The signature must name a real public method with exact parameter types on the given target interface.","triggerScenarios":"@Signature(type = StatementHandler.class, method = \"prepared\", args = {Connection.class}) — wrong name, wrong arg count, wrong arg types/order, or a method that only exists on a different target interface.","commonSituations":"Upgrading MyBatis across versions where target-interface method signatures changed (classic: Executor.query gained BoundSql/CacheKey overloads); typos in method names; assuming a method exists on StatementHandler when it is on ResultSetHandler.","solutions":["Cross-check the method name and full parameter list against the exact MyBatis version's interface source (Executor, ParameterHandler, ResultSetHandler, StatementHandler).","After a MyBatis upgrade, review every @Signature for changed parameter lists (e.g. six-arg Executor.query).","Use parameterized args to catch drift at compile time instead of hard-coded Class literals."],"exampleFix":"// before\n@Intercepts(@Signature(type = StatementHandler.class, method = \"prepare\", args = {Connection.class}))\n// after\n@Intercepts(@Signature(type = StatementHandler.class, method = \"prepare\", args = {Connection.class, Integer.class}))","handlingStrategy":"validation","validationCode":"// startup self-check of signatures\nfor (Signature s : interceptor.getClass().getAnnotation(Intercepts.class).value()) {\n  s.type().getMethod(s.method(), s.args()); // throws NoSuchMethodException early, with a clear message\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["After any MyBatis version bump, re-verify every @Signature against the new interface javadoc.","Write one unit test per interceptor that boots a Configuration with the plugin registered, so signature errors fail the build, not production."],"tags":["mybatis","plugin","interceptor","signature","upgrade"],"backgroundTag":null,"analyzedSha":"008069adb1b089579b5dcba87ee591908b263274","analyzedAt":"2026-08-14T13:07:10.264Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}