Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 3.16.0 does not work any more #1546

Closed
abrod opened this issue Aug 1, 2024 · 29 comments · Fixed by #1547
Closed

Version 3.16.0 does not work any more #1546

abrod opened this issue Aug 1, 2024 · 29 comments · Fixed by #1547
Labels
bug Something isn't working

Comments

@abrod
Copy link

abrod commented Aug 1, 2024

Extension Name: vscode-gradle
Extension Version: 3.16.0
OS Version: Windows
VSCode version: 1.91.1
JAVA_HOME: C:\Program Files\java\openjdk-11

Describe the bug
When I start VSCode the following 2 errors pop up:

  • No connection to gradle server. Try restarting the server.
  • The Gradle client was unable to connect. Try re-connecting.

But reloading did not help. A also tried a new installation and deleted the ~/.vscode and ~/AppData/Roaming/Code folder

To Reproduce
This happens on my computer, with the following files:

  • .vscode/settings.json file
{
    "java.compile.nullAnalysis.mode": "automatic",
    "java.import.gradle.java.home": "/C/Program Files/java/openjdk-8",
    "java.configuration.updateBuildConfiguration": "interactive",
}
  • test\gradlew
  • test\gradlew.bat
  • test\build.gradle
apply plugin: 'java'
  • test\gradle\wrapper\gradle-wrapper.properties (version gradle-5.2.1-bin.zip)
  • test\gradle\wrapper\gradle-wrapper.jar

Expected behavior
This should work as in version 3.15.0

Screenshots
No screenshots

Output from "Gradle for Java"
[info] [gradle-server] ERROR: JAVA_HOME is set to an invalid directory: /C/Program Files/java/openjdk-8
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
[warn] [gradle-server] Gradle server stopped
[error] Error connecting to gradle server: The channel has been closed
[error] The client has state: SHUTDOWN

Does the bug still exist if you disable all other extensions?
Moving to the previous version 3.15.0 helps (as a workarround)

Additional context
I have to continue with these old version gradle 5, java 8

@abrod abrod added the bug Something isn't working label Aug 1, 2024
@jdneo
Copy link
Member

jdneo commented Aug 1, 2024

We are aware of this, working on a fix right now...

@abrod
Copy link
Author

abrod commented Aug 1, 2024

Thanks, then I will wait for the next release version

@jdneo
Copy link
Member

jdneo commented Aug 1, 2024

We just released 3.16.1

Please try it and let us know if it solves the problem.

@MonkeyDoDev
Copy link

I think this needs to be reopened. This is NOT fixed for me. I am a Flutter developer incase that is relevant.

@jdneo
Copy link
Member

jdneo commented Aug 1, 2024

@MonkeyDoDev Can you provide more information like logs, sample project,

@MonkeyDoDev
Copy link

Hi @jdneo

I'm a self-taught 'muddle alonger' and wouldn't have the foggiest how to provide you with a sample project i'm afraid.

I don't receive any log feed at all when i open VS studio, but i get the popups shown in the provided screenshot.

Notably, this was not a problem until i upgraded Flutter the other day to its latest version.

gradle_plugin_error

@jdneo
Copy link
Member

jdneo commented Aug 1, 2024

@MonkeyDoDev Is there any output in the channel Gradle for Java?

@MonkeyDoDev
Copy link

@jdneo yes i've attached that here incase it helps
Screenshot 2024-08-01 at 12 58 20

@jdneo
Copy link
Member

jdneo commented Aug 1, 2024

What's the version of extension gradle for java are you using?

And could you provide the settings you are using?

@MonkeyDoDev
Copy link

@jdneo im using v 3.16.1 and the default settings (i didn't even realise there were settings to change) - I think the screenshot i've attached shows you the relevant settings but let me know if you mean something else

Screenshot 2024-08-01 at 13 06 45

@jdneo
Copy link
Member

jdneo commented Aug 1, 2024

Ok.

What's the file content if you trigger Preferences: Open User Settings (JSON) and Preferences: Open Workspace Settings (JSON)?

@MonkeyDoDev
Copy link

@jdneo ive attached my user settings JSON here. The 'Open Workspace Settings (JSON) is an empty file.
user_settings.txt

@abrod
Copy link
Author

abrod commented Aug 1, 2024

Hello @jdneo
For me, there is still the same error with this version 3.16.1. ... same like MonkeyDoDev
I get this output:

[info] [gradle-server] Gradle Server started, listening on 50995
[info] Gradle client connected to server
[info] Java Home: C:\Users\abrod\.vscode\extensions\redhat.java-1.33.0-win32-x64\jre\17.0.11-win32-x86_64
[info] JVM Args: --add-opens,java.base/java.util=ALL-UNNAMED,--add-opens,java.base/java.lang=ALL-UNNAMED,--add-opens,java.base/java.lang.invoke=ALL-UNNAMED,--add-opens,java.prefs/java.util.prefs=ALL-UNNAMED,-XX:MaxMetaspaceSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx512m,-Dfile.encoding=UTF-8,-Duser.country=DE,-Duser.language=de,-Duser.variant
[info] Gradle User Home: C:\Users\abrod\.gradle
[info] Gradle Version: 5.2.1
[error] FAILURE: Build failed with an exception.

* What went wrong:
Could not open cp_init remapped class cache for 1yxyx3yjg2iao3oejct2mvk2n (C:\Users\abrod\.gradle\caches\5.2.1\scripts-remapped\_87d6e232b83f5a110beb039896aba_2t8wcjqpyz5ur7ceqp1emiejp\1yxyx3yjg2iao3oejct2mvk2n\cp_init3ca90766b0adfce53d4b035e7e9dc5fe).
> Could not open cp_init generic class cache for initialization script 'C:\Users\abrod\AppData\Local\Temp\87d6e232b83f5a110beb039896aba6b830789bc69eca07bef534a9b7ecc4dec3.gradle' (C:\Users\abrod\.gradle\caches\5.2.1\scripts\1yxyx3yjg2iao3oejct2mvk2n\cp_init\cp_init3ca90766b0adfce53d4b035e7e9dc5fe).
   > Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

CONFIGURE FAILED in 3s
[error] [gradle-server] Could not run build action using connection to Gradle distribution 'https://.../gradle-5.2.1-bin.zip'.
[error] Error getting build for g:\...\test: Could not run build action using connection to Gradle distribution 'https://.../gradle-5.2.1-bin.zip'.
[info] Found 0 tasks

@jdneo
Copy link
Member

jdneo commented Aug 2, 2024

@abrod What if you set the setting java.import.gradle.java.home to your local jdk installation, like jdk8 or 11?

@jdneo
Copy link
Member

jdneo commented Aug 2, 2024

@MonkeyDoDev The error in your screen shows that a JDK 11 is used to launch the gradle server. While in a recent change, we upgrade the gradle server compile target to jdk 17.

In the implementation we have logic to search valid jdks (>17):

const javaRuntimes = await listJdks();
const validJdks = javaRuntimes.find((r) => r.version!.major >= REQUIRED_JDK_VERSION);
if (validJdks !== undefined) {
return validJdks.homedir;
}
. I don't know why a wrong jdk is picked in your case. wired...

@MonkeyDoDev
Copy link

@jdneo ahh... it seems i simply needed to update the JDK on my machine to version 17 from the oracle website. Fixed now. Thanks for the help

@jdneo
Copy link
Member

jdneo commented Aug 2, 2024

@MonkeyDoDev Good to know the issue is fixed. Though ideally, the gradle server should not be launched if no jdk 17 is found.

This indicates that something wrong with the jdk detection logic. Filed an issue for further investigation: #1551

@geoplan-junghak
Copy link

@jdneo I need to build a project with Gradle 6.8 and Java 11, similar to @abrod.
However, it seems that from version 3.16.1, the minimum requirement for the Gradle server is Java 17.
If the value of java.import.gradle.java.home is set to lower than 17, the Gradle server fails to start. If it is set to 17 or higher, the Gradle server runs, but the project build fails.
Do I have to use vscode-gradle version 3.15.0 to build the project with Java 11?

@jdneo
Copy link
Member

jdneo commented Aug 2, 2024

@geoplan-junghak Did you install redhat.java extension?

@geoplan-junghak
Copy link

@jdneo Yes, I installed it.

@abrod
Copy link
Author

abrod commented Aug 2, 2024

Hello @jdneo
JAVA_HOME is on java17. So as far as I understood, this version is only needed for the extension.
Here are my settings:

System Environment:

JAVA_HOME=C:\Program Files\java\openjdk-17
PATH=C:\Program Files\java\openjdk-17\bin;%PATH%

UserSettings (JSON)

    "java.configuration.runtimes": [
        {
            "name": "JavaSE-1.8",
            "path": "C:\\Program Files\\java\\openjdk-8",
            "default": true
        },
        {
            "name": "JavaSE-17",
            "path": "C:\\Program Files\\java\\openjdk-17"
        },
        {
            "name": "JavaSE-21",
            "path": "C:\\Program Files\\java\\openjdk-21"
        }
    ],
    "java.jdt.ls.java.home": "C:\\Program Files\\java\\openjdk-17",

so default jdk for vscode is 17

.vscode/settings.json:

    "java.import.gradle.java.home": "C:\\Program Files\\java\\openjdk-8",

this is needed for the build of the gradle file (because we use gradle 5)

Output of version 3.16.1

[info] [gradle-server] Gradle Server started, listening on 56017
[info] Gradle client connected to server
[info] Java Home: C:\Users\abrod\.vscode\extensions\redhat.java-1.33.0-win32-x64\jre\17.0.11-win32-x86_64
[info] JVM Args: --add-opens,java.base/java.util=ALL-UNNAMED,--add-opens,java.base/java.lang=ALL-UNNAMED,--add-opens,java.base/java.lang.invoke=ALL-UNNAMED,--add-opens,java.prefs/java.util.prefs=ALL-UNNAMED,-XX:MaxMetaspaceSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx512m,-Dfile.encoding=UTF-8,-Duser.country=DE,-Duser.language=de,-Duser.variant
[info] Gradle User Home: C:\Users\abrod\.gradle
[info] Gradle Version: 5.2.1
[error] FAILURE: Build failed with an exception.

Output of version 3.15.0

[info] [gradle-server] Server started, listening on 59405
[info] Gradle client connected to server
[info] Java Home: C:\Program Files\java\openjdk-8
[info] JVM Args: -XX:MaxMetaspaceSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx512m,-Dfile.encoding=UTF-8,-Duser.country=DE,-Duser.language=de,-Duser.variant
[info] Gradle User Home: C:\Users\abrod\.gradle
[info] Gradle Version: 5.2.1

@jdneo jdneo reopened this Aug 2, 2024
@jdneo
Copy link
Member

jdneo commented Aug 2, 2024

Should be fixed by #1552

Will schedule a pre-release soon

@jdneo
Copy link
Member

jdneo commented Aug 2, 2024

Please try the pre-release version 3.16.2024080209.

Let me know if the issue still exist.

@geoplan-junghak
Copy link

@jdneo

The build was successfully completed without errors using version v3.16.2024080209 (pre-release).

[info] [gradle-server] Gradle Server started, listening on 65506
[info] Gradle client connected to server
[info] Java Home: C:/Users/sinavro/App/java/java-openjdk-11.0.7.10-1.x86_64
[info] JVM Args: --add-opens,java.base/java.util=ALL-UNNAMED,--add-opens,java.base/java.lang=ALL-UNNAMED,--add-opens,java.base/java.lang.invoke=ALL-UNNAMED,--add-opens,java.prefs/java.util.prefs=ALL-UNNAMED,-XX:MaxMetaspaceSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xms256m,-Xmx512m,-Dfile.encoding=UTF-8,-Duser.country=KR,-Duser.language=ko,-Duser.variant
[info] Gradle User Home: C:\Users\sinavro\.gradle
[info] Gradle Version: 6.8.3

CONFIGURE SUCCESSFUL in 2s
[info] Found 46 tasks

Thank you for your help.

@abrod
Copy link
Author

abrod commented Aug 2, 2024

I used the prerelease version v3.16.2024080209 (pre-release)

and the output was successful

[info] [gradle-server] Gradle Server started, listening on 59872
[info] Gradle client connected to server
[info] Java Home: C:\Program Files\java\openjdk-8
[info] JVM Args: --add-opens,java.base/java.util=ALL-UNNAMED,--add-opens,java.base/java.lang=ALL-UNNAMED,--add-opens,java.base/java.lang.invoke=ALL-UNNAMED,--add-opens,java.prefs/java.util.prefs=ALL-UNNAMED,-XX:MaxMetaspaceSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx512m,-Dfile.encoding=UTF-8,-Duser.country=DE,-Duser.language=de,-Duser.variant
[info] Gradle User Home: C:\Users\abrod\.gradle
[info] Gradle Version: 5.2.1
[info] CONFIGURE SUCCESSFUL in 2s
[info] Found 27 tasks

Thanks a lot ... then I will wait for the next release version.

@jdneo
Copy link
Member

jdneo commented Aug 5, 2024

Fixed by #1552

@jdneo jdneo closed this as completed Aug 5, 2024
@jdneo jdneo pinned this issue Aug 5, 2024
@jdneo
Copy link
Member

jdneo commented Aug 5, 2024

3.16.2 has been released with the fix

@dbmckie
Copy link

dbmckie commented Aug 5, 2024

@abrod What if you set the setting java.import.gradle.java.home to your local jdk installation, like jdk8 or 11?

@jdneo I am experiencing a similar issue upon upgrading from 3.15.0 to 3.16.2.

I am running a project using openjdk-8 and in v3.15.0, without needing to set java.import.gradle.java.home, openjdk-8 is automatically selected as my "Java Home":
[info] Java Home: C:\Program Files\Eclipse Adoptium\jdk-8.0.422.5-hotspot

but now in 3.16.2 I have to configure java.import.gradle.java.home, otherwise "Java Home" is set to:
[info] Java Home: C:\Users\user\.vscode\extensions\redhat.java-1.33.0-win32-x64\jre\17.0.11-win32-x86_64

Which in my case will not download gradle version 6.8.3.

In both cases JavaSE-1.8 is configured with the Language Support For Java extension. Wondering why this additional configuration is required now as it was previously being handled correctly?

@jdneo
Copy link
Member

jdneo commented Aug 6, 2024

Recently, the runtime requirement for the extension is bumped to jdk 17.

The extension will first find a jdk 17 used to launch the gradle server. Unfortunately, the Gradle tooling API will use the jdk that launches it as the java home.

@jdneo jdneo unpinned this issue Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants