Repository navigation
Description
Describe the bug
The embedded MCP server's getResolvedProjectClasspath tool fails for ordinary Spring Boot projects with:
Cannot invoke "org.springframework.ide.vscode.commons.Version.toString()" because the return value of
"org.springframework.ide.vscode.commons.protocol.java.Classpath$CPE.getVersion()" is null
The classpath itself is fine: in the same session getSpringBootVersion, getJavaVersion, getBeanDetails, getRequestMappings and getProjectDiagnostics all answer correctly for the same project, and they are read from that classpath.
Reading the 5.2.0.RELEASE jars, the cause is a missing null check plus a strict file-name convention:
ProjectInformation.getResolvedProjectClasspathmaps every entry withkind == "binary" && !isSystem()throughnew Library(cpe.getPath(), cpe.getVersion().toString()), unguarded.Classpath$CPE.versionis atransientfield, so it is never part of the classpath payload.getVersion()derives it lazily from the entry's file name viaClasspath.getDependencyVersion(...).getDependencyVersionmatches^.+-(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:…)?\.jar$and returnsnullwhen the name does not match — for instance any two-segment version.
So a single jar whose name is not strict three-part SemVer fails the whole tool, and snakeyaml is exactly that case: it ships as snakeyaml-2.4.jar and is a transitive dependency of spring-boot-starter. On a plain spring-boot-starter-web 3.5.5 compile classpath of 63 jars, exactly one — snakeyaml-2.4.jar — fails the pattern, which is enough to make the tool unusable on essentially any Spring Boot application.
To Reproduce
- Any Spring Boot 3.5.x application using
spring-boot-starter-web; confirmsnakeyaml-2.x.jaris on the resolved classpath. - Enable the embedded MCP server:
"boot-java.ai.mcp-server-enabled": true(optionally with"boot-java.ai.mcp-server-port"). - From an MCP client, call
getResolvedProjectClasspathwithprojectNameset to that project. - The call returns an error result with the message above. Other tools in the same sweep answer normally.
Reproduced identically on a Maven project and on a Gradle project.
Sample
https://github.com/luceat-lux-vestra/zed-spring-tools/tree/main/tests/fixtures/spring-boot-basic — a minimal Boot 3.5.5 Maven app; snakeyaml-2.4.jar arrives transitively through spring-boot-starter.
Suggested fix
Guard the mapping so an entry with no derivable version is reported with an absent/null version instead of failing the call, and/or let getDependencyVersion accept two-segment versions. The first alone is enough — a library the tool cannot version is still useful to the caller, whereas today one such entry hides the entire classpath.
Environment
- Spring Tools
5.2.0.RELEASE(vscode-spring-boot2.2.0),spring-boot-language-server-2.2.0-SNAPSHOT-exec.jar - Eclipse Temurin JDK 21.0.11 and 25.0.3, macOS 26.5.2 arm64
One note for transparency: this was observed through a non-VS Code LSP client (a Zed extension that runs this same pinned language server with the same launch flags), so I have not reproduced it in VS Code itself. The defect does not depend on the client: version is transient and is derived inside the language server from the jar file name, so no client supplies or influences the value that comes back null.
Activity
GH-1949: fix parsing of versions with only major and minor parts
martinlippert commentedon Jul 31, 2026
The overall observation that the version parsing doesn't work correctly for libraries like snakeyaml that come without a patch version in their jar name is correct (and fixed now), the error message mentioned above remains unclear to me.
Where exactly is the
Version.toString()method being invoked that the error message is complaining about?luceat-lux-vestra commentedon Jul 31, 2026
It's in
ProjectInformation.getResolvedProjectClasspath, line 100 of the5.2.0.RELEASEtag:Back then
CPE.getVersion()still returnedVersion, which is null for a jar namethat doesn't match the pattern — hence
null.toString()onsnakeyaml-2.4.jar.You can't find it on
mainbecause 8985a0f (#1918, 23 Jun) madegetVersion()return
Stringand dropped the.toString()in the same commit — after the5.2.0.RELEASE build I was running. So the call site is already gone (5.3.0.RELEASE
no longer has it), and an unparseable name now just comes back with a null version
instead of failing the call. Nothing further needed from my side — thanks for the fix.