Skip to content

Refactoring does not work #1408

Closed
Closed

Description

@JanecekPetr

On a fresh installation of STS,

Version: 4.26.0.RELEASE
Build Id: 202410162246

on Windows 11 and Java 23, I created an empty workspace with an otherwise empty demo Spring Boot project using Spring Initializr. When I run ANY Rewrite-provided refactoring, e.g. "Update to Java 17", I get a failure.

Sample

java.lang.reflect.InvocationTargetException
	at org.springframework.tooling.boot.ls.commands.RewriteRefactoringsHandler.lambda$3(RewriteRefactoringsHandler.java:114)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:124)
Caused by: java.util.concurrent.ExecutionException: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Internal error.
	at java.base/java.util.concurrent.CompletableFuture.wrapInExecutionException(CompletableFuture.java:345)
	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:440)
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2117)
	at org.springframework.tooling.boot.ls.commands.RewriteRefactoringsHandler.lambda$3(RewriteRefactoringsHandler.java:112)
	... 1 more
Caused by: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Internal error.
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:220)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:204)
	at org.eclipse.lsp4e.LanguageServerWrapper.lambda$3(LanguageServerWrapper.java:318)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:185)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:97)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:114)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
	[...]

The raw Language Server exception:

[2024-11-13T12:28:15.935529800+01:00] LANGUAGE_SERVER_TO_LSP4E org.eclipse.languageserver.languages.springboot:
{"jsonrpc":"2.0","id":"20","error":{"code":-32603,"message":"Internal error.","data":"java.util.concurrent.CompletionException: java.lang.NoClassDefFoundError: org/opentest4j/TestAbortedException [...]"}}

Extracted the exception:

java.util.concurrent.CompletionException: java.lang.NoClassDefFoundError: org/opentest4j/TestAbortedException
	at java.base/java.util.concurrent.CompletableFuture.wrapInCompletionException(CompletableFuture.java:323)
	[...]
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:189)
Caused by: java.lang.NoClassDefFoundError: org/opentest4j/TestAbortedException
	at org.springframework.ide.vscode.commons.rewrite.gradle.GradleIJavaProjectParser.parseBuildFiles(GradleIJavaProjectParser.java:71)
	at org.springframework.ide.vscode.commons.rewrite.java.ProjectParser.parse(ProjectParser.java:45)
	at org.springframework.ide.vscode.boot.java.rewrite.RewriteRecipeRepository.lambda$apply$25(RewriteRecipeRepository.java:405)
	at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1194)
	... 7 more
Caused by: java.lang.ClassNotFoundException: org.opentest4j.TestAbortedException
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:528)
	... 11 more

Activity

  1. BoykoAlex commented on Nov 13, 2024

    @BoykoAlex
    Contributor

    Thanks for reporting. Something is off with Rewrite Gradle support. Likely we didn't include some JAR libs in the LS. The exception TestAbortedException class cannot be found but this exception is thrown when the Gradle API tooling fails to load the project's model... Will be investigating this...

  2. BoykoAlex commented on Nov 13, 2024

    @BoykoAlex
    Contributor

    @JanecekPetr I'd try Java 21 for the LS process and Eclipse. Java 23 might be the reason of failure to load Gradle model via Gradle Tooling API as the tooling API is based on Gradle 8.9 and may not be compatible with Java 23. Is the project Java 17 or 21?

  3. JanecekPetr commented on Nov 13, 2024

    @JanecekPetr
    Author

    The original project I discovered this on is running on Java 11. The demo project was on 17. I just tried running Eclipse itself (and the LS, I assume, although my default java is 17) on 21, that did not help.

    I'll try to get a clean run on a clean installation with just 17 all over it everywhere tomorrow.

  4. BoykoAlex commented on Nov 14, 2024

    @BoykoAlex
    Contributor

    It should work now with the snapshot build. (Snapshots: https://cdn.spring.io/spring-tools/snapshot/STS4/nightly-distributions.html)
    (Fixed via 8de092b, Rewrite Gradle model fix: openrewrite/rewrite-gradle-tooling-model@8b72f12. Once new version of Rewrite Gradle Tooling API is out we'll remove the workaround)

  5. JanecekPetr commented on Nov 14, 2024

    @JanecekPetr
    Author

    You are a gentleman, and a scholar. Thank you!

  6. added this to the 4.27.0.RELEASE milestone on Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

for: eclipsetheme: refactoringtype: bug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions