Skip to content

MCP tool getResolvedProjectClasspath throws NPE when a classpath jar's file name is not strict SemVer (e.g. snakeyaml-2.4.jar) #1949

Closed

Description

@luceat-lux-vestra

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.getResolvedProjectClasspath maps every entry with kind == "binary" && !isSystem() through new Library(cpe.getPath(), cpe.getVersion().toString()), unguarded.
  • Classpath$CPE.version is a transient field, so it is never part of the classpath payload. getVersion() derives it lazily from the entry's file name via Classpath.getDependencyVersion(...).
  • getDependencyVersion matches ^.+-(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:…)?\.jar$ and returns null when 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

  1. Any Spring Boot 3.5.x application using spring-boot-starter-web; confirm snakeyaml-2.x.jar is on the resolved classpath.
  2. Enable the embedded MCP server: "boot-java.ai.mcp-server-enabled": true (optionally with "boot-java.ai.mcp-server-port").
  3. From an MCP client, call getResolvedProjectClasspath with projectName set to that project.
  4. 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-boot 2.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

  1. added this to the 5.4.0.RELEASE milestone on Jul 29, 2026
  2. added a commit that references this issue on Jul 31, 2026
  3. martinlippert commented on Jul 31, 2026

    @martinlippert
    Member

    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?

  4. luceat-lux-vestra commented on Jul 31, 2026

    @luceat-lux-vestra
    Author

    It's in ProjectInformation.getResolvedProjectClasspath, line 100 of the
    5.2.0.RELEASE tag:

    .map(cpe -> new Library(cpe.getPath(), cpe.getVersion().toString()))
    

    Back then CPE.getVersion() still returned Version, which is null for a jar name
    that doesn't match the pattern — hence null.toString() on snakeyaml-2.4.jar.

    You can't find it on main because 8985a0f (#1918, 23 Jun) made getVersion()
    return String and dropped the .toString() in the same commit — after the
    5.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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions