vscode-java-debug
vscode-java-debug copied to clipboard
Wrong Java runtime used JRE 11 vs. JRE 17
Wrong Java runtime used
Environment
- Operating System: ubuntu linux
- JDK version: Corretto-17.0.9.8.1
- Visual Studio Code version: latest
- Java extension version: latest and prerelease
- Java Debugger extension version: latest and prerealease
Steps To Reproduce
- Trying to debug spring boot
No special launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Launch Application",
"request": "launch",
"mainClass": "de.xxx.xxx.Application",
"projectName": "xxx-application",
"env": {
"SPRING_PROFILES_ACTIVE": "debug",
},
"vmArgs": "-Xms128m -Xmx128m"
}
]
}
Java Configure Runtime for Projects outputs wrong java version
Should be 17 (works on other enviroments - E.g. eclipse)
Current Result
Error: Unable to initialize main class de.ewe.gisatfuture.servicehub.Application
Caused by: java.lang.UnsupportedClassVersionError: org/springframework/web/servlet/config/annotation/WebMvcConfigurer has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0
Expected Result
Debugger should simply run
Additional Informations
Workaround: mvn spring-boot:run does work
Could you pls share a sample project to reproduce the issue?
Must have something to do with multi module projects, since the parent one does not seem to recognize the java version as shown in the screenshot
<properties>
<java.version>17</java.version>
[...]
</properties>
I assume it is not necessary to include the java.version property in every child module using <parent>(...)</parent> declaration in its child.
Another workaround is exactly this, adding <java.version>17</java.version> to all child modules which is IMO a bad idea
All projects i am working with are now affected and can no longer be debugged with this extension
I tried with https://github.com/spring-guides/gs-multi-module/tree/main/initial, where I moved "java.version" property from child pom.xml to parent pom.xml, it still worked. All child modules were recognized as version 17. Could you share a sample project in github for us to reproduce it?
Unfortunately a cannot quickly provide you an example project.
Another workaround is to configure java.configuration.runtimes as follow
"java.configuration.runtimes": [
{
"name": "JavaSE-17",
"path": "/usr/lib/jvm/java-17-amazon-corretto",
"default": true
}
],
After this I could still see in the footer that the wrong path is being used (my old /usr/lib/jvm/openjdk-11-(...))
So I completely removed the old openjdk JVM.
Finally debugging worked again. BUT STILL JavaSE-11 is visualized with the "new" amazon-coretto-17
How do I fix the "Language Level" property?
BTW Even after the java-jdk-17 is being pulled, still shows Java 11 in the "Runtime for Projects" while every parent *.pom has java.version 17 defined
The Java language server reads the language level from your pom.xml. It appears that there is an issue when importing your Maven projects, but it is difficult to determine the root cause from just a few screenshots.
I can provide you with the pom.xml contents
Frontend module: (mostly javascript) Backend Module: (java part)