{"record":{"id":"bd8b80860e625153","repo":"spring-projects/spring-framework","slug":"advice-object-is-neither-a-supported-subinter","errorCode":null,"errorMessage":"Advice object [{}] is neither a supported subinterface of [org.aopalliance.aop.Advice] nor an [org.springframework.aop.Advisor]","messagePattern":"Advice object \\[(.+?)\\] is neither a supported subinterface of \\[org\\.aopalliance\\.aop\\.Advice\\] nor an \\[org\\.springframework\\.aop\\.Advisor\\]","errorType":"exception","errorClass":"UnknownAdviceTypeException","httpStatus":null,"severity":"error","filePath":"spring-aop/src/main/java/org/springframework/aop/framework/adapter/DefaultAdvisorAdapterRegistry.java","lineNumber":65,"sourceCode":"\n\n\t/**\n\t * Create a new DefaultAdvisorAdapterRegistry, registering well-known adapters.\n\t */\n\tpublic DefaultAdvisorAdapterRegistry() {\n\t\tregisterAdvisorAdapter(new MethodBeforeAdviceAdapter());\n\t\tregisterAdvisorAdapter(new AfterReturningAdviceAdapter());\n\t\tregisterAdvisorAdapter(new ThrowsAdviceAdapter());\n\t}\n\n\n\t@Override\n\tpublic Advisor wrap(Object adviceObject) throws UnknownAdviceTypeException {\n\t\tif (adviceObject instanceof Advisor advisor) {\n\t\t\treturn advisor;\n\t\t}\n\t\tif (!(adviceObject instanceof Advice advice)) {\n\t\t\tthrow new UnknownAdviceTypeException(adviceObject);\n\t\t}\n\t\tif (advice instanceof MethodInterceptor) {\n\t\t\t// So well-known it doesn't even need an adapter.\n\t\t\treturn new DefaultPointcutAdvisor(advice);\n\t\t}\n\t\tfor (AdvisorAdapter adapter : this.adapters) {\n\t\t\t// Check that it is supported.\n\t\t\tif (adapter.supportsAdvice(advice)) {\n\t\t\t\treturn new DefaultPointcutAdvisor(advice);\n\t\t\t}\n\t\t}\n\t\tthrow new UnknownAdviceTypeException(advice);\n\t}\n\n\t@Override\n\tpublic MethodInterceptor[] getInterceptors(Advisor advisor) throws UnknownAdviceTypeException {\n\t\tList<MethodInterceptor> interceptors = new ArrayList<>(3);\n\t\tAdvice advice = advisor.getAdvice();","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/69bf83ad716d0cfc4b0520a19b4d8b24c79d1538/spring-aop/src/main/java/org/springframework/aop/framework/adapter/DefaultAdvisorAdapterRegistry.java#L47-L83","documentation":"Thrown as UnknownAdviceTypeException by DefaultAdvisorAdapterRegistry.wrap when the object passed in is neither an Advisor nor an Advice (the first 'instanceof Advice' check at line 64 fails). The registry only knows how to wrap Advice subinterfaces and existing Advisors; anything else is rejected with this exact message.","triggerScenarios":"Calling advisorAdapterRegistry.wrap(someObject) or ProxyFactory.addAdvice(someObject) / addAdvisor via a value that is a plain POJO. Also reached indirectly through ProxyFactoryBean when an interceptorNames entry resolves to a non-Advice bean (which is then surfaced as error 90).","commonSituations":"Passing the target bean (or a String, configuration object) into addAdvice by mistake; mis-typed interceptor beans; refactoring that changed a class to no longer implement an Advice interface.","solutions":["Pass only Advice or Advisor instances to wrap()/addAdvice()/addAdvisor().","If you intended to set the target, use setTarget/setTargetSource instead.","If the bean should be advice, make its class implement MethodBeforeAdvice/AfterReturningAdvice/ThrowsAdvice/MethodInterceptor."],"exampleFix":"// before\nproxyFactory.addAdvice(myPlainServiceBean); // not an Advice\n\n// after\nproxyFactory.setTarget(myPlainServiceBean);\nproxyFactory.addAdvice(new MyMethodInterceptor()); // implements MethodInterceptor","handlingStrategy":"type-guard","validationCode":"if (!(obj instanceof Advice) && !(obj instanceof Advisor)) {\n  throw new IllegalArgumentException(obj + \" is not Advice or Advisor\");\n}\nadvisorRegistry.wrap(obj);","typeGuard":"static boolean isAdviceOrAdvisor(Object o) {\n  return o instanceof Advice || o instanceof Advisor;\n}","tryCatchPattern":"try { Advisor a = registry.wrap(obj); }\ncatch (UnknownAdviceTypeException e) {\n  if (e.getMessage().startsWith(\"Advice object [\")) { /* pass real Advice/Advisor */ }\n  throw e;\n}","preventionTips":["Type-check advice objects before addAdvice()/wrap().","Use setTarget for target beans, never addAdvice."],"tags":["spring-aop","advice","advisor-registry","configuration"],"backgroundTag":null,"analyzedSha":"69bf83ad716d0cfc4b0520a19b4d8b24c79d1538","analyzedAt":"2026-08-09T15:32:58.770Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}