{"record":{"id":"766fe173a667d639","repo":"alibaba/spring-cloud-alibaba","slug":"type-static-method-can-not-be-found-in-bean-bea","errorCode":null,"errorMessage":"{type} static method can not be found in bean[{beanName}]. The right method signature is {blockClass}#{blockMethod}{argsStr}, please check your class name, method name and arguments","messagePattern":"(.+?) static method can not be found in bean\\[(.+?)\\]\\. The right method signature is (.+?)#(.+?)(.+?), please check your class name, method name and arguments","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-sentinel/src/main/java/com/alibaba/cloud/sentinel/custom/SentinelBeanPostProcessor.java","lineNumber":142,"sourceCode":"\t\t\tthrow new IllegalArgumentException(type + \" method attribute exists but \"\n\t\t\t\t\t+ type + \" class attribute is not exists in bean[\" + beanName + \"]\");\n\t\t}\n\t\tClass[] args;\n\t\tif (type.equals(SentinelConstants.URLCLEANER_TYPE)) {\n\t\t\targs = new Class[] {String.class};\n\t\t}\n\t\telse {\n\t\t\targs = new Class[] {HttpRequest.class, byte[].class,\n\t\t\t\t\tClientHttpRequestExecution.class, BlockException.class};\n\t\t}\n\t\tString argsStr = Arrays.toString(\n\t\t\t\tArrays.stream(args).map(clazz -> clazz.getSimpleName()).toArray());\n\t\tMethod foundMethod = ClassUtils.getStaticMethod(blockClass, blockMethod, args);\n\t\tif (foundMethod == null) {\n\t\t\tlog.error(\n\t\t\t\t\t\"{} static method can not be found in bean[{}]. The right method signature is {}#{}{}, please check your class name, method name and arguments\",\n\t\t\t\t\ttype, beanName, blockClass.getName(), blockMethod, argsStr);\n\t\t\tthrow new IllegalArgumentException(type\n\t\t\t\t\t+ \" static method can not be found in bean[\" + beanName\n\t\t\t\t\t+ \"]. The right method signature is \" + blockClass.getName() + \"#\"\n\t\t\t\t\t+ blockMethod + argsStr\n\t\t\t\t\t+ \", please check your class name, method name and arguments\");\n\t\t}\n\n\t\tClass<?> standardReturnType;\n\t\tif (type.equals(SentinelConstants.URLCLEANER_TYPE)) {\n\t\t\tstandardReturnType = String.class;\n\t\t}\n\t\telse {\n\t\t\tstandardReturnType = ClientHttpResponse.class;\n\t\t}\n\n\t\tif (!standardReturnType.isAssignableFrom(foundMethod.getReturnType())) {\n\t\t\tlog.error(\"{} method return value in bean[{}] is not {}: {}#{}{}\", type,\n\t\t\t\t\tbeanName, standardReturnType.getName(), blockClass.getName(),\n\t\t\t\t\tblockMethod, argsStr);","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/alibaba/spring-cloud-alibaba/blob/115d5901102009492e05d5ec18c3f79cad4077d0/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-sentinel/src/main/java/com/alibaba/cloud/sentinel/custom/SentinelBeanPostProcessor.java#L124-L160","documentation":"After class and method are both provided, Sentinel uses Spring's ClassUtils.getStaticMethod to locate a public static method with the exact argument signature the framework expects. For urlCleaner it is (String); for block/fallback it is (HttpRequest, byte[], ClientHttpRequestExecution, BlockException). If no such static method exists on the class, this IllegalArgumentException is thrown with the required signature embedded in the message.","triggerScenarios":"Naming a method that does not exist, is not static, or has the wrong parameters, e.g. an instance method handleBlock(HttpRequest,byte[],ClientHttpRequestExecution,BlockException) or a static method with only (BlockException). Mismatching the urlCleaner signature (String) with a block-style signature also triggers it.","commonSituations":"Renaming the handler method after wiring it. Marking the method non-static. Copying a block handler as a urlCleaner without changing its parameters.","solutions":["Make the method public static with the exact signature shown in the error's argsStr.","For urlCleaner use 'public static String clean(String url)'; for block/fallback use 'public static ClientHttpResponse handle(HttpRequest, byte[], ClientHttpRequestExecution, BlockException)'.","Confirm the method name in the attribute matches the declared name exactly (case-sensitive).","Ensure the class is the one referenced by the -class attribute, not a subclass."],"exampleFix":"// before\npublic ClientHttpResponse handle(HttpRequest req, byte[] body, ClientHttpRequestExecution exec, BlockException ex) { ... }\n// after\npublic static ClientHttpResponse handle(HttpRequest req, byte[] body, ClientHttpRequestExecution exec, BlockException ex) { ... }","handlingStrategy":"validation","validationCode":"void requireStaticHandler(Class<?> c, String name, Class<?>... args) throws NoSuchMethodException {\n  java.lang.reflect.Method m = c.getMethod(name, args);\n  if (!java.lang.reflect.Modifier.isStatic(m.getModifiers()))\n    throw new IllegalStateException(name + \" must be static with signature \" + Arrays.toString(args));\n}","typeGuard":"static boolean isStaticHandler(Class<?> c, String name, Class<?>... args) {\n  try { return java.lang.reflect.Modifier.isStatic(c.getMethod(name, args).getModifiers()); }\n  catch (NoSuchMethodException e) { return false; }\n}","tryCatchPattern":null,"preventionTips":["Keep handler methods public static with the documented signature.","Unit-test handler classes for the exact parameter types.","Copy the signature from the official docs, not from memory."],"tags":["sentinel","resttemplate","reflection","config-validation"],"backgroundTag":null,"analyzedSha":"115d5901102009492e05d5ec18c3f79cad4077d0","analyzedAt":"2026-08-14T04:47:13.900Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}