redhat-developer / vscode-java

Java Language Support for Visual Studio Code
Eclipse Public License 2.0
2.07k stars 430 forks source link

java.util.concurrent.CompletionException: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: org.gradle.tooling.BuildException: Could not fetch model of type 'GradleSourceSets' using connection to Gradle distribution #3497

Closed alchemylove closed 7 months ago

alchemylove commented 7 months ago

[provide a description of the issue]

Environment
Steps To Reproduce
  1. Error in initial when starting vscode image !ENTRY org.eclipse.jdt.ls.core 4 0 2024-02-14 19:47:29.372 !MESSAGE Initialization failed !STACK 0 java.util.concurrent.CompletionException: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: org.gradle.tooling.BuildException: Could not fetch model of type 'GradleSourceSets' using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-8.6-bin.zip'. at java.base/java.util.concurrent.CompletableFuture.reportJoin(Unknown Source) at java.base/java.util.concurrent.CompletableFuture.join(Unknown Source) at com.microsoft.gradle.bs.importer.GradleBuildServerProjectImporter.importToWorkspace(GradleBuildServerProjectImporter.java:171) at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.importProjects(ProjectsManager.java:162) at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.initializeProjects(ProjectsManager.java:124) at org.eclipse.jdt.ls.core.internal.handlers.InitHandler$1.runInWorkspace(InitHandler.java:263) at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:43) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63) Caused by: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: org.gradle.tooling.BuildException: Could not fetch model of type 'GradleSourceSets' using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-8.6-bin.zip'. at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:209) at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:193) at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194) at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94) at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.base/java.util.concurrent.FutureTask.run(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.base/java.lang.Thread.run(Unknown Source)
alchemylove commented 7 months ago

addtiionnal info:

i created some build.gradle by spring initializr. all com.example.demo couldn't work.

lombok: compileOnly 'org.projectlombok:lombok:1.18.30' annotationProcessor 'org.projectlombok:lombok:1.18.30'

snjeza commented 7 months ago

I can't reproduce the issue using JDK 21, gradle 8.6, spring demo @alchemylove Could you attach a project example or your build.gradle?

alchemylove commented 7 months ago

■build.gradle

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.2.2'
    id 'io.spring.dependency-management' version '1.1.4'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'

java {
    sourceCompatibility = '21'
}

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    compileOnly 'org.projectlombok:lombok'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

tasks.named('test') {
    useJUnitPlatform()
}

■setting.gradle rootProject.name = 'demo'

■vscode extensions

>code --list-extensions
ms-ceintl.vscode-language-pack-ja
redhat.java
visualstudioexptteam.intellicode-api-usage-examples
visualstudioexptteam.vscodeintellicode
vmware.vscode-boot-dev-pack
vmware.vscode-spring-boot
vscjava.vscode-gradle
vscjava.vscode-java-debug
vscjava.vscode-java-dependency
vscjava.vscode-java-pack
vscjava.vscode-java-test
vscjava.vscode-maven
vscjava.vscode-spring-boot-dashboard
vscjava.vscode-spring-initializr

I'm experiencing the same issue with both vscode and cursor. My teammates are facing the same issue as well. We have set the JAVA_HOME and other configurations. It's completely unclear what the problem is. Could someone please advise?

snjeza commented 7 months ago

I still can't reproduce the issue. @alchemylove Could you try the following:

alchemylove commented 7 months ago

@snjeza Amazing! So it worked. thanks so much.