##[Error] Java.lang.UnsupportedClassVersionError

Hi everyone,

I’m new using Sonarqube so I’m not an expert. I have an Integration between SonarQube and Azure Devops Pipelines, now, when I run the Pipeline I’m getting this message when the Run Code Analysis begin:
“ERROR: Error during SonarScanner execution INFO: ##[error]java.lang.UnsupportedClassVersionError: org/sonar/batch/bootstrapper/EnvironmentInformation has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0”.

I set these values in the wrapper config file, but the error persist:
wrapper.java.command=/usr/lib/jvm/java-11-openjdk-11.0.12.0.7-0.el8_4.x86_64/bin/java
#wrapper.java.command=java

Notes:
I have Sonarqube Community Edition v9.0.1 (build 46107) installed on Centos 8.

I was checking the Sonarqube’s docs but I don’t know how to solve this. I’d really appreciate if someone could explain what changes I need to make to the system or what kind of variables I have to set.

Thank you and my best regards!

Hi,

Welcome to the community!

A UnsupportedClassVersionError is always about the Java program (in this case the scanner) not being compatible with the underlying JRE/JDK version you’re trying to use. In this case it’s saying the java version is too new. When I look up what 52.0 translates to in normal language, I see that it’s Java 8. That tells me you’re using a rather old version of the scanner. You need to upgrade that, although I can’t give you precise instructions for that in the Azure context. The docs may help.

Regarding the wrapper config file, that’s about the SonarQube server itself and not relevant in this context.

 
HTH,
Ann

Hi Ann,
Thanks for your reply. I was checking the docs and I applied some configurations but the error persist. I’ll try to install an older version of sonarqube like 8.9 LTS and see what happens.

Regards,

Hi,

This is not about installing an older version of SonarQube. It’s about using the newest scanner version and making sure you have the correct version of Java to support it.

 
Ann

I am also having same error with sonar version 9.3. If anyone have got the solution, please share detail

Hi @sanjeev2281,

What did you make of my previous answers in the thread?

 
Ann

Hi,

I have a similar Issue, but with the latest versions of software:

From AzureDevOps (local agent) I am trying to run SonarQubeAnalyze and got the following error:

##[error]java.lang.UnsupportedClassVersionError: org/sonar/batch/bootstrapper/EnvironmentInformation has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
...
2023-02-13T09:52:19.7836465Z ##[error]The process '[path]\_tasks\SonarQubePrepare_15b84ca1-a72f-4a2a-a403-89b77a063157\5.11.1\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
2023-02-13T09:52:19.7893220Z ##[section]Finishing: SonarQubeAnalyze

On the server hosting the Azure DevOps agent the following versions are installed

  • Java™ SE Runtime Environment (build 1.8.0_361-b09) - Latest
  • And the Agent installs SonarQube 5.11 - Latest

The pipeline tasks are:

steps:
- task: SonarQubePrepare@5
  inputs:
    SonarQube: '**********'
    scannerMode: 'MSBuild'
    projectKey: '**********'
    projectName: '**********'
- powershell: dotnet build '$(solution)' -c '$(buildConfiguration)'
  displayName: Run Build
- task: SonarQubeAnalyze@5
- task: SonarQubePublish@5
  inputs:
    pollingTimeoutSec: '300'

Also, above I am a little confused because: The scannerMode is MSBuild, but I have a dotnet build. I guess this should worm, because MSBuild mode defines to scan Microsof technologies.

Can you please suggest what could be the reason or the error?

Thank you and my best regards!

Hi @kricer,

This thread is nearly 1y old, and normally I would say you should have opened a new thread and referenced this one as necessary, per the FAQ.

However, in this case, it’s useful to me, since I can easily repeat what I said in the post just before yours:

I.e. the answer is already there^.

 
Ann