You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Vscode Spring Boot Tools 1.40.0 prevents Java Unit Tests from Running/Debugging when JDK 11 is specified #893
Description
Vscode Spring Boot Tools 1.40.0 prevents Java Unit Tests from Running/Debugging when JDK 11 is specified in spring-boot.ls.java.home setting.
To Reproduce
Prerequisite: VSCode with Java Extension Pack and Spring Boot Extension Pack (version of VSCode : 1.73.1)
Clone the sample java project linked below
Download an install an OpenJDK 11
Open VSCode on the sample java project folder.
Edit the settings.json of VSCode and set value of spring-boot.ls.java.home to path of installed JDK 11
Go to Test viewlet and try to run/debug the only unit test of the project
Thanks @ogarry80 for reporting this. But why are you setting this preference to a manually installed JDK 11? This setting is used to identify the JDK to run the tooling itself - and is not related to the Java version of your projects at all. That is why I am wondering why you are setting this preference. By default, it uses the JDK 17 that comes embedded in the Java tooling in VSCode.
Aside from that, the tooling requires a JDK 17 to run on - and forcing the tooling to run on a JDK 11 will most likely break it (which seems to be the case for you). Keep in mind that this preference is unrelated to your projects. They can continue to compile against and run on Java 11 - independent of the JDK that is used to run the tooling itself.
Thanks for the quick reply @martinlippert.
In fact we have a spring boot project with lots of years old legacy code running only on JDK 11.
Maybe i did something wrong but if i don't set this setting manually to point on JDK11 the spring boot app does not starts at all.
It was working well with this manual setting until release of 1.38 or 1.39, i can't remember exactly
@martinlippert
I removed the setting and I am now able to run the spring boot app as well as the unit tests.
You are right, I certainly misused this setting.
@martinlippert I also had the spring-boot.ls.java.home setting set to a JDK 11. I don't recall the exact reason why, but at some point in the past I had to set this in order for the extension to work. Because of this, I recently was suddenly unable to run or debug Java applications or tests in VS Code until I was able to devote some time to research and find the culprit. This was extremely frustrating.
If I could make a suggestion, I've noticed other VS Code extensions will check their configured JDK version at startup, and if the version is insufficient, or the setting is misconfigured, popup an error message noting that a specific version of Java is required and the extension will not work until this is resolved. This prompts me to check and set the relevant setting. I know what to do, and what to expect if I don't do that.
I think that is a much better way to handle this requirement than what currently happens in Spring Boot Tools, which is nothing (no error message, no logging, nothing), just silent failure that creates end user confusion and frustration.
Understand and be prepared that some users may have this setting set for any reason, such as to fix an issue in the past, and handle that accordingly and communicate it with the user.
@baincd You are absolutely right, we need to make sure that such a wrong JDK setting is reported to the user instead of failing silently here. No question about that. Filed #903 for this.
Activity
martinlippert commentedon Nov 17, 2022
Thanks @ogarry80 for reporting this. But why are you setting this preference to a manually installed JDK 11? This setting is used to identify the JDK to run the tooling itself - and is not related to the Java version of your projects at all. That is why I am wondering why you are setting this preference. By default, it uses the JDK 17 that comes embedded in the Java tooling in VSCode.
Aside from that, the tooling requires a JDK 17 to run on - and forcing the tooling to run on a JDK 11 will most likely break it (which seems to be the case for you). Keep in mind that this preference is unrelated to your projects. They can continue to compile against and run on Java 11 - independent of the JDK that is used to run the tooling itself.
ogarry80 commentedon Nov 17, 2022
Thanks for the quick reply @martinlippert.
In fact we have a spring boot project with lots of years old legacy code running only on JDK 11.
Maybe i did something wrong but if i don't set this setting manually to point on JDK11 the spring boot app does not starts at all.
It was working well with this manual setting until release of 1.38 or 1.39, i can't remember exactly
ogarry80 commentedon Nov 17, 2022
@martinlippert
I removed the setting and I am now able to run the spring boot app as well as the unit tests.
You are right, I certainly misused this setting.
Thanks a lot for your help and clarification :)
martinlippert commentedon Nov 17, 2022
No worries, happy to hear that everything is working fine again and thanks for letting us know.
baincd commentedon Nov 23, 2022
@martinlippert I also had the
spring-boot.ls.java.homesetting set to a JDK 11. I don't recall the exact reason why, but at some point in the past I had to set this in order for the extension to work. Because of this, I recently was suddenly unable to run or debug Java applications or tests in VS Code until I was able to devote some time to research and find the culprit. This was extremely frustrating.If I could make a suggestion, I've noticed other VS Code extensions will check their configured JDK version at startup, and if the version is insufficient, or the setting is misconfigured, popup an error message noting that a specific version of Java is required and the extension will not work until this is resolved. This prompts me to check and set the relevant setting. I know what to do, and what to expect if I don't do that.
I think that is a much better way to handle this requirement than what currently happens in Spring Boot Tools, which is nothing (no error message, no logging, nothing), just silent failure that creates end user confusion and frustration.
Understand and be prepared that some users may have this setting set for any reason, such as to fix an issue in the past, and handle that accordingly and communicate it with the user.
martinlippert commentedon Nov 23, 2022
@baincd You are absolutely right, we need to make sure that such a wrong JDK setting is reported to the user instead of failing silently here. No question about that. Filed #903 for this.