{"record":{"id":"46f6dddb1718cad6","repo":"spring-projects/spring-ai","slug":"failed-to-load-default-system-message-suffix-from","errorCode":null,"errorMessage":"Failed to load default system message suffix from classpath resource","messagePattern":"Failed to load default system message suffix from classpath resource","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"advisors/spring-ai-tool-search-advisor/src/main/java/org/springframework/ai/chat/client/advisor/toolsearch/ToolSearchToolCallingAdvisor.java","lineNumber":481,"sourceCode":"\t\t}\n\n\t\t/**\n\t\t * Builds and returns a new ToolSearchToolCallingAdvisor instance with the\n\t\t * configured properties.\n\t\t * @return a new ToolSearchToolCallingAdvisor instance\n\t\t * @throws IllegalArgumentException if required parameters are null or invalid\n\t\t */\n\t\t@Override\n\t\tpublic ToolSearchToolCallingAdvisor build() {\n\n\t\t\tif (!StringUtils.hasText(this.systemMessageSuffix)) {\n\t\t\t\ttry {\n\t\t\t\t\tthis.systemMessageSuffix = new DefaultResourceLoader()\n\t\t\t\t\t\t.getResource(\"classpath:/DEFAULT_SYSTEM_PROMPT_SUFFIX.md\")\n\t\t\t\t\t\t.getContentAsString(StandardCharsets.UTF_8);\n\t\t\t\t}\n\t\t\t\tcatch (Exception ex) {\n\t\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\t\t\"Failed to load default system message suffix from classpath resource\", ex);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tAssert.notNull(this.toolIndex, \"toolIndex is required\");\n\t\t\treturn new ToolSearchToolCallingAdvisor(getToolCallingManager(), getAdvisorOrder(),\n\t\t\t\t\tgetToolExecutionEligibilityChecker(), this.toolIndex,\n\t\t\t\t\tObjects.requireNonNull(this.systemMessageSuffix), this.referenceToolNameAccumulation,\n\t\t\t\t\tthis.maxResults, this.isConversationHistoryEnabled(), this.sessionIdKeyName, this.evictionStrategy);\n\t\t}\n\n\t\t@Override\n\t\tprotected ToolCallingAdvisor.Builder<?> newCopy() {\n\t\t\treturn new Builder<>();\n\t\t}\n\n\t\t@Override\n\t\tpublic ToolCallingAdvisor.Builder<?> copy() {","sourceCodeStart":463,"sourceCodeEnd":499,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/advisors/spring-ai-tool-search-advisor/src/main/java/org/springframework/ai/chat/client/advisor/toolsearch/ToolSearchToolCallingAdvisor.java#L463-L499","documentation":"The ToolSearchToolCallingAdvisor.Builder appends a default suffix to the system prompt by reading the classpath resource classpath:/DEFAULT_SYSTEM_PROMPT_SUFFIX.md shipped in the advisor jar. If that resource cannot be found or read, the builder throws this IllegalArgumentException. It essentially always means the jar is corrupted, shaded incorrectly, or the resource was excluded at build time.","triggerScenarios":"Calling ToolSearchToolCallingAdvisor.builder().build() (directly or via auto-configuration) when the resource DEFAULT_SYSTEM_PROMPT_SUFFIX.md is absent from the classpath or unreadable.","commonSituations":"ProGuard/shade plugins stripping resources, fat-jar repackaging that drops .md files, dependency exclusions removing resource files, or running from an exploded classpath where resources were not copied to target/classes.","solutions":["Verify the jar contains the file: unzip -l spring-ai-tool-search-advisor-*.jar | grep DEFAULT_SYSTEM_PROMPT_SUFFIX.md; if missing, re-download/repair the dependency.","Check your Maven/Gradle build for resource filtering or exclusion rules (e.g. maven-resources-plugin nonFilteredFileExtensions, shading includes) that drop *.md resources.","Run mvn clean and rebuild — stale target/classes without copied resources commonly causes this in IDE runs.","Disable build plugins (minimizeJar/shrink) that remove 'unused' resources and retry."],"exampleFix":"<!-- before: maven-shade-plugin strips resources -->\n<filters><filter><artifact>*:*</artifact><excludes><exclude>*.md</exclude></excludes></filter></filters>\n\n<!-- after -->\n<filters><filter><artifact>*:*</artifact><excludes><exclude>META-INF/*.SF</exclude></excludes></filter></filters>","handlingStrategy":"validation","validationCode":"if (new DefaultResourceLoader().getResource(\"classpath:/DEFAULT_SYSTEM_PROMPT_SUFFIX.md\").getContentAsString(StandardCharsets.UTF_8) == null) {\n    throw new IllegalStateException(\"advisor jar resources missing — re-check packaging\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    advisor = ToolSearchToolCallingAdvisor.builder().build();\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"classpath resource\")) {\n        // repackage or reinstall the spring-ai-tool-search-advisor jar\n    }\n    throw e;\n}","preventionTips":["Do not exclude *.md resources when shading/minimizing jars","Run mvn clean after dependency changes","Verify jar contents with unzip -l after packaging","Avoid aggressive minimizeJar settings"],"tags":["classpath","resources","startup","build"],"backgroundTag":"resource-not-found","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}