An API incompatibility was encountered (Encountered error upon execute of mvn sonar:sonar on project )

Error encountered:
Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155:sonar: 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

SonarQube

  • Community Edition
  • Version 9.0 (build 45539)

My java version is 1.8

Running it via docker.

Steps taken:

  1. Go to project folder (project is built in maven)
  2. Execute mvn sonar:sonar etc specified command followed on SonarQube

It seems like a java version mismatch. What SonarQube version is compatible with a Java 8?

Hi,

Welcome to the community!

Rather than downgrading your SonarQube version (baaaad idea. Think of all the features you’d loose. Think of all bug fixes and vulnerability patches.) you need to split the Java version you compile to from the version you analyze with. This is addressed by the docs.

 
HTH,
Ann

HI Ann,

We have upgraded from 7.6>7.9>8.9>9.0.

And now we are facing the same issue,

plugin:3.9.0.2155:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155:sonar: 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 have gone through the documentation which you suggested above, but how can we use sonar.java.jdkHome and where? And this jdk should be on jenkins slave or sonarqube server?
We dont use the sonarqube properties file, we have jenkins build where we have maven config and only sonar:sonar for scans. How can we manage this scenario.

Thanks in advance.

Hi @cipher,

From the docs I reference above:

When using SonarScanner to perform analyses of project, the property sonar.java.source can to be set manually in sonar-project.properties .

 
Ann

Where does one find sonar-project.properties?

Hi @bpkimball,

Welcome to the community!

If one is using SonarScanner, one will find it in the project root. For other scanners, the general method of setting property values will vary. But one can always override on the analysis command line with -D[property name]=[property value].

 
HTH,
Ann