{"id":"c9cdf43408bcbe58","repo":"spring-projects/spring-framework","slug":"cannot-be-found-on","errorCode":null,"errorMessage":"{} cannot be found on {}","messagePattern":"(.+?) cannot be found on (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanInstanceSupplier.java","lineNumber":407,"sourceCode":"\t/**\n\t * Performs lookup of the {@link Constructor}.\n\t */\n\tprivate static class ConstructorLookup extends ExecutableLookup {\n\n\t\tprivate final Class<?>[] parameterTypes;\n\n\t\tConstructorLookup(Class<?>[] parameterTypes) {\n\t\t\tthis.parameterTypes = parameterTypes;\n\t\t}\n\n\t\t@Override\n\t\tpublic Executable get(RegisteredBean registeredBean) {\n\t\t\tClass<?> beanClass = registeredBean.getMergedBeanDefinition().getBeanClass();\n\t\t\ttry {\n\t\t\t\treturn beanClass.getDeclaredConstructor(this.parameterTypes);\n\t\t\t}\n\t\t\tcatch (NoSuchMethodException ex) {\n\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\t\"%s cannot be found on %s\".formatted(this, beanClass.getName()), ex);\n\t\t\t}\n\t\t}\n\n\t\t@Override\n\t\tpublic String toString() {\n\t\t\treturn \"Constructor with parameter types [%s]\".formatted(toCommaSeparatedNames(this.parameterTypes));\n\t\t}\n\t}\n\n\n\t/**\n\t * Performs lookup of the factory {@link Method}.\n\t */\n\tprivate static class FactoryMethodLookup extends ExecutableLookup {\n\n\t\tprivate final Class<?> declaringClass;\n","sourceCodeStart":389,"sourceCodeEnd":425,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/e8729d043887bf0d0baf91e062e909b56eb2b708/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanInstanceSupplier.java#L389-L425","documentation":"ConstructorLookup.get calls Class.getDeclaredConstructor(parameterTypes) to locate the constructor the AOT machinery intends to use; if no constructor matches the captured parameter types it throws NoSuchMethodException, which Spring wraps as IllegalArgumentException with this message. The bean class does not expose a constructor with the expected signature.","triggerScenarios":"AOT captured a set of constructor parameter types (from the resolved InstantiationDescriptor) but the bean class on the runtime classpath no longer declares a constructor with exactly those parameter types.","commonSituations":"Bean class changed (constructor signature edited, an overload added/removed) without regenerating AOT artifacts; runtime classpath has a different version of the class than AOT used; Kotlin/record/inner-class constructor quirks where the synthetic parameter differs.","solutions":["Regenerate AOT/native artifacts after changing the bean class or its dependencies.","Confirm the bean class on the runtime classpath is the same version used at AOT build time.","For Kotlin/inner classes, verify the constructor shape (e.g. synthetic params) matches what AOT expects, or annotate the intended constructor explicitly."],"exampleFix":"// before: AOT captured Service(Repo) but runtime class only has Service(Repo, Config)\n// after: align runtime class with AOT and rebuild\n// mvn -Pnative spring-boot:process-aot","handlingStrategy":"validation","validationCode":"Class<?>[] paramTypes = ...; // captured AOT constructor params\nClass<?> beanClass = registeredBean.getBeanClass();\ntry { beanClass.getDeclaredConstructor(paramTypes); }\ncatch (NoSuchMethodException e) {\n  throw new IllegalStateException(\"Constructor \" + Arrays.toString(paramTypes) + \" missing on \" + beanClass);\n}","typeGuard":"boolean constructorExists(Class<?> beanClass, Class<?>[] params) {\n  try { beanClass.getDeclaredConstructor(params); return true; }\n  catch (NoSuchMethodException e) { return false; }\n}","tryCatchPattern":null,"preventionTips":["Regenerate AOT artifacts whenever bean constructors change.","Lock dependency versions between AOT build and runtime.","For Kotlin/inner classes, verify synthetic parameters match AOT expectations."],"tags":["spring","aot","native","constructor","classloading"],"analyzedSha":"e8729d043887bf0d0baf91e062e909b56eb2b708","analyzedAt":"2026-08-04T19:07:39.725Z","schemaVersion":2}