{"record":{"id":"19a5e62e8fc7a9c4","repo":"mybatis/mybatis-3","slug":"no-intercepts-annotation-was-found-in-interceptor","errorCode":null,"errorMessage":"No @Intercepts annotation was found in interceptor {}","messagePattern":"No @Intercepts annotation was found in interceptor (.+?)","errorType":"exception","errorClass":"PluginException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/apache/ibatis/plugin/Plugin.java","lineNumber":70,"sourceCode":"\n  @Override\n  public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {\n    try {\n      Set<Method> methods = signatureMap.get(method.getDeclaringClass());\n      if (methods != null && methods.contains(method)) {\n        return interceptor.intercept(new Invocation(target, method, args));\n      }\n      return method.invoke(target, args);\n    } catch (Exception e) {\n      throw ExceptionUtil.unwrapThrowable(e);\n    }\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) {","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/mybatis/mybatis-3/blob/008069adb1b089579b5dcba87ee591908b263274/src/main/java/org/apache/ibatis/plugin/Plugin.java#L52-L88","documentation":"Plugin.getSignatureMap() requires every Interceptor to carry the @Intercepts annotation; it is the only source of @Signature entries telling MyBatis which target interface methods to proxy. Without it the plugin cannot be wired at all.","triggerScenarios":"Registering an Interceptor implementation (via <plugins> in XML, Configuration.addInterceptor, or auto-detection) whose class lacks @Intercepts.","commonSituations":"Copy-pasted interceptor with the annotation accidentally removed; interceptor subclassing an annotated base but the subclass is registered while the annotation lives on the base (getAnnotation does not inherit @Intercepts unless @Inherited); migrating to a different plugin mechanism.","solutions":["Add @Intercepts(@Signature(type = Executor.class, method = \"update\", args = {MappedStatement.class, Object.class})) to the interceptor class.","Declare the annotation directly on the registered class, not only on a parent — @Intercepts is not @Inherited.","Verify the class actually implements org.apache.ibatis.plugin.Interceptor."],"exampleFix":"// before\npublic class SqlLogger implements Interceptor { ... }\n// after\n@Intercepts(@Signature(type = Executor.class, method = \"update\", args = {MappedStatement.class, Object.class}))\npublic class SqlLogger implements Interceptor { ... }","handlingStrategy":"validation","validationCode":"if (interceptor.getClass().getAnnotation(Intercepts.class) == null) {\n  throw new IllegalStateException(interceptor.getClass().getName() + \" must be annotated with @Intercepts\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Put @Intercepts directly on every registered interceptor class (it is not inherited).","Add a startup assertion/scan that all Interceptor beans carry @Intercepts."],"tags":["mybatis","plugin","interceptor","annotation"],"backgroundTag":null,"analyzedSha":"008069adb1b089579b5dcba87ee591908b263274","analyzedAt":"2026-08-14T13:07:10.264Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}