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

Wrong Java runtime used JRE 11 vs. JRE 17 #1406

Open
ole1986 opened this issue Nov 3, 2023 · 7 comments
Open

Wrong Java runtime used JRE 11 vs. JRE 17 #1406

ole1986 opened this issue Nov 3, 2023 · 7 comments

Comments

@ole1986
Copy link

ole1986 commented Nov 3, 2023

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
  1. 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

image

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

@testforstephen
Copy link
Contributor

Could you pls share a sample project to reproduce the issue?

@ole1986
Copy link
Author

ole1986 commented Nov 3, 2023

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

@ole1986
Copy link
Author

ole1986 commented Nov 8, 2023

All projects i am working with are now affected and can no longer be debugged with this extension

@testforstephen
Copy link
Contributor

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?

@ole1986
Copy link
Author

ole1986 commented Nov 8, 2023

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-(...))
image

So I completely removed the old openjdk JVM.
Finally debugging worked again. BUT STILL JavaSE-11 is visualized with the "new" amazon-coretto-17
image

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

image

@testforstephen
Copy link
Contributor

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.

@ole1986
Copy link
Author

ole1986 commented Nov 8, 2023

I can provide you with the pom.xml contents

Frontend module: (mostly javascript)
Backend Module: (java part)

Downloads.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants