Error installing SonarQube on Azure DevOps server edition

Hi,
I am trying to integrate SonarQube into my Azure DevOps pipeline - my DevOps pipeline is installed on my an in-house windows server as opposed to the cloud. I am getting a java mismatch error while running the ‘Run Code Analysis’ step. Can you please help? Here are some details:

I know SonarQube requires Java 11 installed - I did go and install that on my server and I also added it to the path but I still get this error -

Here is what running the comman java --version on command prompt tells me -

 C:\Users\******>java --version
java 11.0.9 2020-10-20 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.9+7-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.9+7-LTS, mixed mode)

Error I get -

 2021-09-13T21:04:13.2773783Z ==============================================================================
2021-09-13T21:04:15.1301095Z [command]C:\Windows\system32\cmd.exe /D /S /C "C:\agent\_work\_tasks\SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055\4.22.0\sonar-scanner\bin\sonar-scanner.bat"
2021-09-13T21:04:15.6925192Z INFO: Scanner configuration file: C:\agent\_work\_tasks\SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055\4.22.0\sonar-scanner\bin\..\conf\sonar-scanner.properties
2021-09-13T21:04:15.6972363Z INFO: Project root configuration file: NONE
2021-09-13T21:04:15.7299748Z INFO: SonarScanner 4.6.2.2472
2021-09-13T21:04:15.7322065Z INFO: Java 1.8.0_281 Oracle Corporation (32-bit)
2021-09-13T21:04:15.7519076Z INFO: Windows Server 2012 R2 6.3 x86
2021-09-13T21:04:16.2554965Z INFO: User cache: C:\Users\***\.sonar\cache
2021-09-13T21:04:16.8091363Z INFO: Scanner configuration file: C:\agent\_work\_tasks\SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055\4.22.0\sonar-scanner\bin\..\conf\sonar-scanner.properties
2021-09-13T21:04:16.8134115Z INFO: Project root configuration file: NONE
2021-09-13T21:04:16.8262969Z INFO: Analyzing on SonarQube server 9.0.1
2021-09-13T21:04:16.8266665Z INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent)
2021-09-13T21:04:16.8356469Z INFO: ------------------------------------------------------------------------
2021-09-13T21:04:16.8357527Z INFO: EXECUTION FAILURE
2021-09-13T21:04:16.8361222Z INFO: ------------------------------------------------------------------------
2021-09-13T21:04:16.8361954Z INFO: Total time: 1.210s
2021-09-13T21:04:16.8543066Z INFO: Final Memory: 4M/15M
2021-09-13T21:04:16.8544480Z INFO: ------------------------------------------------------------------------
2021-09-13T21:04:16.8593124Z ##[error]ERROR: Error during SonarScanner execution
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
2021-09-13T21:04:16.8605312Z ERROR: Error during SonarScanner execution
2021-09-13T21:04:16.8606249Z 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

Must-share information (formatted with Markdown):

  • which versions are you using - SonarQube
  • what are you trying to achieve - integrating sonarQube with Azure DevOps pipeline
  • what have you tried so far to achieve this - installed correct version of java.

Hi,

Welcome to the community!

I’m not an Azure expert (OK, I have no experience on Azure at all) but I can see from your log that analysis is picking up the wrong Java version.

You’ve already demonstrated that the default Java on the instance is Java 11. This means there’s a configuration somewhere that explicitly points the analyzer at Java 8. At a guess, there’s a JAVA_HOME variable configured somewhere. Can you see if you can find that?

 
HTH,
Ann

Satish,
I am encountering the same error. How were you able to resolve it?

Apologies - I did not respond to Ann’s note too earlier as well - I had to make sure that I had the right version of java installed.
Once I did that, I was able to add a new pipeline variable in my specific Azure DevOps build pipeline called JAVA_HOME - it just needed to point to the location where the relevant java version was installed.

2 Likes

A post was split to a new topic: Error in SonarQube scan

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