3

I'm currently migrating a project from java 8 to java 11, and have been using Sonar scanner, with gradle, to send the code to SonaQube. After migrating to Open JDK 11, I amd getting the following error when running the gradle sonarqube tasks:

java.lang.IllegalArgumentException: Unsupported class file major version 55

I have read online that the scanner should be run with jdk 8, even though the analysis can be run on an version of java files, but have not been able to figure this out.

Ideally, I would be able to run gradle sonarqube with the Java 11 JDK. I found another question seeming to have success with Java 11 using Maven, but their error is different, and I don't think their solution would apply to me.

Is this problem solvable, or will I need to wait for Sonar Scanner to have support for JDK 11?

Caleb Hulbert
  • 145
  • 2
  • 11
  • I doubt that sonarqube or gradle support Java11 fully even. Can you share their versions used as well in the question please? – Naman Oct 11 '18 at 19:38
  • I have the same issue with sonar-scanner (org.sonarqube) 2.6.2 and SonarQube 7.1 with SonarJava plugin updated to 5.6. Looks like the Gradle plugin is still not been updated for Java 11 compatibility. – Kutzi Jan 03 '19 at 13:41
  • 1
    @Kutzi I didn't quite find the solution, but I found a work around. I use Java 11 for all my development efforts, but switch to Java 8 exclusively to run the sonarqube task with gradle. I call the task as so: `gradle sonarqube -Psonar8 -Dorg.gradle.java.home=$JAVA_HOME_8`. JAVA_HOME_8 points to my Java 8 JDK. And when gradle get -Psonar, it changes the target and source compatibility ( e.g. `targetCompatibility = project.hasProperty('sonar8') ? '8' : '10'`) as well as excluding all tasks which try to compile or run the code (e.g. `gradle.startParameter.excludedTaskNames += "compileJava"`) – Caleb Hulbert Jan 10 '19 at 20:49
  • @CalebHulbert : I am also looking for same point. our development is done in JDK11. But I need to use gradle sonarqube to run sonar analysis.since gradle sonar scanner is yet to support JDK11. I am new to gradle, Can you please explain the work around you mentioned in detail ? Thanks in advance. – Vishnu300 Jan 30 '19 at 19:29
  • @Caleb Hulbert: what is the sonar scanner gradle plugin version used and sonar qube server version used ? – Vishnu300 Jan 31 '19 at 04:45
  • @Vishnu300 I'm using the sonarque plugin version `2.6.2` and the sonarqube server is version `1.0.0.0`. If I have the time, I think I'll post the full solution I had as an answer. For now, hopefully this helps! – Caleb Hulbert Jan 31 '19 at 16:18

1 Answers1

0

If someone like me this will helpful.

Source code Java 8(55), with jenkins and sonarqube scanner.

My error was

INFO: SonarScanner 4.6.2.2472
INFO: Java 11.0.11 AdoptOpenJDK (64-bit)
.....
java.lang.IllegalArgumentException: Unsupported class file major version 55

Check this link : Why does sonar-scanner force the usage of the embedded JRE?

And change your sonar-scanner.bat or sonar-scanner.sh to use:

use_embedded_jre=false
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
jornathan
  • 646
  • 5
  • 13