java.lang.UnsupportedClassVersionError when analysing a .Net Core c# project

I seem to be unable to run the prepare step on our self hosted (Windows) VM:

  • ALM used: Azure DevOps
  • CI system used: Azure DevOps
  • Scanner command used when applicable (private details masked)
  • Languages of the repository: C#
  • Error observed: 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
  • Steps to reproduce
  • Potential workaround: Use MS Hosted build agent

When using a self hosted build agent running on a Windows VM, the prepare step fails with the above error. The VM has the latest Java RE (Oracle 1.8.0_333). Running the job on a MS Hosted agent works fine.

Information form the failing job:

Calling the SonarScanner CLI…

INFO: Scanner configuration file: C:\DevOps\Agent02_work_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.27.0\classic-sonar-scanner-msbuild\sonar-scanner-4.6.2.2472\bin..\conf\sonar-scanner.properties

INFO: Project root configuration file: C:\DevOps\Agent02_work\6.sonarqube\out\sonar-project.properties

INFO: SonarScanner 4.6.2.2472

INFO: Java 1.8.0_333 Oracle Corporation (64-bit)

INFO: Windows Server 2019 10.0 amd64

INFO: User cache: C:\Windows\system32\config\systemprofile.sonar\cache

INFO: Scanner configuration file: C:\DevOps\Agent02_work_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.27.0\classic-sonar-scanner-msbuild\sonar-scanner-4.6.2.2472\bin..\conf\sonar-scanner.properties

INFO: Project root configuration file: C:\DevOps\Agent02_work\6.sonarqube\out\sonar-project.properties

INFO: Analyzing on SonarCloud

INFO: Default locale: “en_US”, source code encoding: “windows-1252” (analysis is platform dependent)

INFO: ------------------------------------------------------------------------

INFO: EXECUTION FAILURE

INFO: ------------------------------------------------------------------------

INFO: Total time: 2.348s

INFO: Final Memory: 6M/123M

INFO: ------------------------------------------------------------------------

##[error]ERROR: Error during SonarScanner execution

ERROR: Error during SonarScanner execution

##[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

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

What can I do to have a succesful pipeline on a self hosted agent?

Hi,

Welcome to the community!

This means you’re using a version of Java that isn’t supported to run analysis.

This part is telling you that your version of Java is too old (it can go the other way too).

Now the frustrating part is what versions 55.0 and 52.0 actually mean.

52.0 is Java 8
55.0 is Java 11

And with the docs we can confirm that Java 11 or 17 is required for analysis.

So this means you need to upgrade the Java version on your build agent.

 
HTH,
Ann

Hi Ann,

Thank you for the quick reply! As I’m a .Net guy, my knowledge of Java is limited… Which JRE would I need then? The agent VM has the latest JRE from java.com.

Kind rgards,

Sikke

Hi Sikke,

Wow! Thanks for the link. I don’t know what games Oracle is playing there, but Java 8 is not the latest version. That’s Java 18 (but it’s not supported for analysis).

You can download Oracle’s implementation of Java 17 from here and the OpenJDK implementation from here

 
HTH,
Ann

Thanks Ann, that solved my issue!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.