SonarQube Migration Version 7.9.3 to Version 8.9.1

I am running two SonarQube versions, SonarQube 7.9.3 and 8.9.1, with gradle build we see below error with 8.9.1 but not with 7.9.3, could you please help me what is issue.

org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(324) The type java.lang.StringBuilder cannot be resolved. It is indirectly referenced from required .class files 
**10:37:51**    at org.eclipse.jdt.internal.compiler.problem.ProblemHandler.handle(ProblemHandler.java:162) 
**10:37:51**    at org.eclipse.jdt.internal.compiler.problem.ProblemHandler.handle(ProblemHandler.java:229) 
**10:37:51**    at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.handle(ProblemReporter.java:2624) 
**10:37:51**    at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.isClassPathCorrect(ProblemReporter.java:5081) 
**10:37:51**    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromCompoundName(LookupEnvironment.java:1791) 
**10:37:51**    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromConstantPoolName(LookupEnvironment.java:1821) 
**10:37:51**    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromConstantPoolName(LookupEnvironment.java:1829) 
**10:37:51**    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromSignature(LookupEnvironment.java:1899) 
**10:37:51**    at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createMethod(BinaryTypeBinding.java:857) 
**10:37:51**    at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createMethods(BinaryTypeBinding.java:1053) 
**10:37:51**    at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.cachePartsFrom(BinaryTypeBinding.java:602) 
**10:37:51**    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:1055) 
**10:37:51**    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:1036) 
**10:37:51**    at org.eclipse.jdt.internal.compiler.Compiler.accept(Compiler.java:308) 
**10:37:51**    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:326) 
**10:37:51**    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getType(LookupEnvironment.java:1734) 
**10:37:51**    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getType(LookupEnvironment.java:1701) 
**10:37:51**    at org.eclipse.jdt.core.dom.ASTUtils.resolveType(ASTUtils.java:58) 
**10:37:51**    at org.sonar.java.model.JSema.resolveType(JSema.java:125) 
**10:37:51**    at org.sonar.java.model.JSema.lambda$getClassType$6(JSema.java:108) 
**10:37:51**    at org.sonar.java.model.JSema$$Lambda$1113.00000000E523F970.apply(Unknown Source) 
**10:37:51**    at java.util.HashMap.computeIfAbsent(HashMap.java:1138)

Hello,

Can you make sure that you are using the latest version of the SonarQube gradle scanner?

This looks to me that it might be related to running the analysis on a different JDK than the one used for build.

Also, could you share a reproducing code snippet? It would help diagnosing what is happening.

Cheers,
Michael

Thanks for the picking up my request Michael.

SonarQube gradle scanner : I am using “org.sonarqube” version “3.1.1”
in build.gradle i am using
plugins {
id “org.sonarqube” version “3.1.1”
}
regarding analysis and run: source code is compatible to java 8, hence I am using jdk 8 for both build and scan, but my sonarqube running on jdk11.
code snippet : I am not sure which line/file throwing this error because in error it is not showing any file names

Same code builds and runs/scans fine with Sonarqube 7.9.3 but gives errors with Sonarqube 8.9.1

sonarpocsvc-1.0.0.1.zip (28.9 KB)
Hi Michael,

I created sample sonarpoc to analyse the issue (uploaded here sonarpocsvc-1.0.0.1.zip),
observed that in file colruyt.sonarpocsvcejb.bo.MyBo.java if I change String to Object issue is not occurring. Not sure what is the cause.

Previously reported issue with StringBuilder is from my business application.

below error is from POC (sonarpocsvc application) which I uploaded in previous reply.

org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(324) The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files
        at org.eclipse.jdt.internal.compiler.problem.ProblemHandler.handle(ProblemHandler.java:162)
        at org.eclipse.jdt.internal.compiler.problem.ProblemHandler.handle(ProblemHandler.java:229)
        at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.handle(ProblemReporter.java:2624)
        at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.isClassPathCorrect(ProblemReporter.java:5081)
        at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromCompoundName(LookupEnvironment.java:1791)
        at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromConstantPoolName(LookupEnvironment.java:1821)
        at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromConstantPoolName(LookupEnvironment.java:1829)
        at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromSignature(LookupEnvironment.java:1899)
        at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createFields(BinaryTypeBinding.java:741)
        at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.cachePartsFrom(BinaryTypeBinding.java:601)
        at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:1055)
        at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:1036)
        at org.eclipse.jdt.internal.compiler.Compiler.accept(Compiler.java:308)
        at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:257)
        at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getType(LookupEnvironment.java:1732)
        at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getType(LookupEnvironment.java:1701)
        at org.eclipse.jdt.core.dom.ASTUtils.resolveType(ASTUtils.java:58)
        at org.sonar.java.model.JSema.resolveType(JSema.java:125)
        at org.sonar.java.model.JSema.lambda$getClassType$6(JSema.java:108)
        at org.sonar.java.model.JSema$$Lambda$2198.000000001E6421B0.apply(Unknown Source)
        at java.util.HashMap.computeIfAbsent(HashMap.java:1137)
        at org.sonar.java.model.JSema.getClassType(JSema.java:107)
        at org.sonar.java.model.JType.isSubtypeOf(JType.java:56)
        at org.sonar.java.checks.CustomCryptographicAlgorithmCheck.isJavaSecurityMessageDigestSubClass(CustomCryptographicAlgorithmCheck.java:55)
        at org.sonar.java.checks.CustomCryptographicAlgorithmCheck.visitNode(CustomCryptographicAlgorithmCheck.java:46)
        at org.sonar.java.model.VisitorsBridge$IssuableSubsciptionVisitorsRunner.lambda$visit$6(VisitorsBridge.java:287)
        at org.sonar.java.model.VisitorsBridge$IssuableSubsciptionVisitorsRunner$$Lambda$2231.000000001D58D6A0.accept(Unknown Source)
        at org.sonar.java.model.VisitorsBridge$IssuableSubsciptionVisitorsRunner.lambda$forEach$9(VisitorsBridge.java:303)
        at org.sonar.java.model.VisitorsBridge$IssuableSubsciptionVisitorsRunner$$Lambda$2230.000000001EF91B80.run(Unknown Source)
        at org.sonar.java.model.VisitorsBridge.runScanner(VisitorsBridge.java:159)
        at org.sonar.java.model.VisitorsBridge.access$100(VisitorsBridge.java:62)
        at org.sonar.java.model.VisitorsBridge$IssuableSubsciptionVisitorsRunner.forEach(VisitorsBridge.java:303)
        at org.sonar.java.model.VisitorsBridge$IssuableSubsciptionVisitorsRunner.visit(VisitorsBridge.java:289)
        at org.sonar.java.model.VisitorsBridge$IssuableSubsciptionVisitorsRunner.visitChildren(VisitorsBridge.java:273)
        at org.sonar.java.model.VisitorsBridge$IssuableSubsciptionVisitorsRunner.visit(VisitorsBridge.java:293)
        at org.sonar.java.model.VisitorsBridge$IssuableSubsciptionVisitorsRunner.run(VisitorsBridge.java:264)
        at org.sonar.java.model.VisitorsBridge.visitFile(VisitorsBridge.java:139)
        at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:127)
        at org.sonar.java.ast.JavaAstScanner.scan(JavaAstScanner.java:79)
        at org.sonar.java.JavaSquid.scanSources(JavaSquid.java:130)
        at org.sonar.java.JavaSquid.scan(JavaSquid.java:116)
        at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:105)
        at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor$$Lambda$1871.000000001BF91170.run(Unknown Source)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
        at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
        at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:392)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:388)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.ja

Hi Michael,

Could you please help me, let me know if it is not clear or need more info.

Thanks,
Rukesh

Hi Michael,

observed that, If I use JDK11 for gradle build and analysis(sonar scan), not getting this error,
looks like
no issue with Sonarqube 8.9 (server runs on java 11) + gradle (code build and scan with java11)
no issue with Sonarqube 7.9 (server runs on java 11) + gradle (code build and scan with java8)

but issue occurs with Sonarqube 8.9 (server runs on java 11) + gradle (code build and scan with java8)

could you please help me how to resolve this issue.

Thanks,
Rukesh

Hi,

Could you please help me, main question can i use java jdk 8 + gradle 3.3 scanner scanner + sonarqube 8.9.1 combination.

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube : 8.9.1
    Scanner/Plugin: Gradle 3.3 (SonarScanner for Gradle)
  • what are you trying to achieve
    Build and Scan java8 compatible project using JDK8
  • what have you tried so far to achieve this
    I am able to build and run/scan the application but getting below error with sonarqube task
    org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(324) The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files
    at org.eclipse.jdt.internal.compiler.problem.ProblemHandler.handle(ProblemHandler.java:162)
    at org.eclipse.jdt.internal.compiler.problem.ProblemHandler.handle(ProblemHandler.java:229)
    at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.handle(ProblemReporter.java:2624)
    at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.isClassPathCorrect(ProblemReporter.java:5081)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromCompoundName(LookupEnvironment.java:1791)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromConstantPoolName(LookupEnvironment.java:1821)

Thanks,
Rukesh

Hi @rukesh,

As said by @Michael, the issue is from the inconsistence of Java version that you use to build the project and that you use to execute the analysis.

Would you like to share the full logs for the further investigation?
Best regards,
Fan

Hi Fan,

There is no inconsistence of Java version.
getting issue if i use java8 for both build and analysis.
but no issue if i use java 11 for build and analysis.

please find the attached logs for both scenarios.

log_with_jdk8.txt (31.4 KB)
log_with_jdk11.txt (1.7 KB)

Thanks&Regards,
Rukesh.

Hi Fan/Michael,

Any update on this, it is blocking our SonarQube migration.
could you please help.

Regards,
Rukesh.