{"record":{"id":"0c5247a775b97225","repo":"spring-projects/spring-ai","slug":"error-when-registering-bedrock-types","errorCode":null,"errorMessage":"error when registering Bedrock types","messagePattern":"error when registering Bedrock types","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/aot/BedrockRuntimeHints.java","lineNumber":71,"sourceCode":"\tprivate final Log log = LogFactory.getLog(BedrockRuntimeHints.class);\n\n\tprivate final MemberCategory[] memberCategories = MemberCategory.values();\n\n\tprivate final Collection<TypeReference> allClasses;\n\n\tBedrockRuntimeHints() {\n\t\tthis.allClasses = this.find(this.rootPackage);\n\t}\n\n\t@Override\n\tpublic void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {\n\t\ttry {\n\t\t\tthis.registerBedrockRuntimeService(hints);\n\t\t\tthis.registerSerializationClasses(hints);\n\t\t\tthis.registerResources(hints);\n\t\t} //\n\t\tcatch (Throwable ex) {\n\t\t\tthis.log.warn(\"error when registering Bedrock types\", ex);\n\t\t}\n\t}\n\n\tprivate void registerBedrockRuntimeService(RuntimeHints hints) {\n\t\tvar pkg = this.rootPackage + \".services.bedrockruntime\";\n\t\tvar all = new HashSet<TypeReference>();\n\t\tfor (var clzz : this.allClasses) {\n\t\t\tif (clzz.getName().contains(\"Bedrock\") && clzz.getName().contains(\"Client\")) {\n\t\t\t\tall.add(clzz);\n\t\t\t}\n\t\t}\n\t\tvar modelPkg = pkg + \".model\";\n\t\tall.addAll(this.find(modelPkg));\n\t\tall.forEach(tr -> hints.reflection().registerType(tr, this.memberCategories));\n\t}\n\n\tprivate void registerSerializationClasses(RuntimeHints hints) {\n\t\tfor (var c : this.allClasses) {","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/aot/BedrockRuntimeHints.java#L53-L89","documentation":"BedrockRuntimeHints.registerHints() registers reflection/serialization/resource hints for GraalVM native image. Any Throwable during registration is only logged at WARN ('error when registering Bedrock types') — not thrown. The risk is silent native-image runtime failures (missing reflection metadata) rather than an immediate crash.","triggerScenarios":"Building a GraalVM native image (or running AOT processing) with the Bedrock model on the classpath when registerBedrockRuntimeService/registerSerializationClasses/registerResources throws — e.g. a class listed for reflection cannot be loaded, or a TypeReference points to a class absent in this Bedrock SDK version.","commonSituations":"Version drift between spring-ai-bedrock and the AWS SDK (class names moved/removed); shaded/relocated AWS SDK jars; native-image builds with a stripped dependency set.","solutions":["Read the logged stack trace following the WARN line to identify which registration step and class failed.","Align the AWS Bedrock SDK version with the one expected by your spring-ai-bedrock release.","Manually add @RegisterReflectionForBinding / runtime hints for the missing classes in your own RuntimeHintsRegistrar as a workaround.","Test the native image early; if the WARN appears but inference works, no action is needed."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// not thrown; watch build logs: if 'error when registering Bedrock types' appears, add manual hints\nstatic class FallbackHints implements RuntimeHintsRegistrar { public void registerHints(RuntimeHints h, ClassLoader cl) { h.reflection().registerType(BedrockAiApi.class, MemberCategory.values()); } }","preventionTips":["Run a native-image smoke test invoking a Bedrock call early in CI","Keep spring-ai-bedrock and AWS SDK versions aligned","Read the WARN stack trace to find which hint registration failed instead of guessing"],"tags":["bedrock","graalvm","native-image","aot","runtime-hints"],"backgroundTag":"native-image-reflection-hints","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}