IntelliJ+Gradle+SonarLint not finding class files in linked mode

Hi,

I have a SonarQube server that runs analysis. However I’m having trouble getting the SonarLint plugin for IntelliJ to work in linked mode. It does work if I unlink but does not use the rules defined on the server.

The code is Java and uses Gradle as a build tool. The error I am seeing appears to be SonarLint unable to find the references to the class files it needs to understand the code. The code is built and the jars do exist. The log implies it knows where the jars are, but then cannot find the classes.

The analysed file does have SonarQube issue when assessed on the server.

Below is a log that unfortunately I’ve had to remove a lot of info from, but I’ve left in as much of what I think is essential. I have not removed any errors.

Configuring analysis with org.sonarlint.intellij.analysis.JavaAnalysisConfigurator
Using configuration of 'com.AAA.BBB' in server 'SonarQube'
Analysing 3 files...
Starting analysis with configuration:
[
  projectKey: com.AAA.BBB
  baseDir: C:\Users\usera\Documents\workspace\BBB
  workDir: C:\Users\usera\Documents\workspace\BBB\.idea\sonarlint
  extraProperties: {sonar.java.target=1.8, sonar.java.source=1.8, sonar.java.libraries=C:/Users/usera/Documents/workspace/BBB;......}
  inputFiles: [
    file://C:/Users/usera/Documents/workspace/BBB/ProjectA/src/test/java/com/co/AAA/BBB/ComponentA.java (UTF-8) [test]
    file://C:/Users/usera/Documents/workspace/BBB/ProjectA/src/test/java/com/co/AAA/BBB/ComponentB.java (UTF-8) [test]
    file://C:/Users/usera/Documents/workspace/BBB/ProjectA/src/test/java/com/co/AAA/BBB/ComponentC.java (UTF-8) [test]
  ]
]

Available languages:
  * Java => "java"
Start analysis
Declared extensions of language Java were converted to java: **/*.java,**/*.jav
Index files
Language of file 'file://C:/Users/usera/Documents/workspace/BBB/ProjectA/src/test/java/com/co/AAA/BBB/ComponentA.java' is detected to be 'java'
Language of file 'file://C:/Users/usera/Documents/workspace/BBB/ProjectA/src/test/java/com/co/AAA/BBB/ComponentB.java' is detected to be 'java'
Language of file 'file://C:/Users/usera/Documents/workspace/BBB/ProjectA/src/test/java/com/co/AAA/BBB/ComponentC.java' is detected to be 'java'
3 files indexed
Quality profiles:
  * java: SOME_LETTERS_HERE (735 rules)
Execute Sensor: JavaSquidSensor
Configured Java source version (sonar.java.source): 8
JavaClasspath initialization
File C:\Users\usera\.gradle\caches\modules-2\files-2.1\com.ongres.scram\client\1.0.0-beta.2\b6abad98aea51da5602d528ba3aa404f568db6bc\client-1.0.0-beta.2.xml was ignored from java classpath
JavaClasspath initialization (done) | time=86ms
JavaTestClasspath initialization
File C:\Users\usera\.gradle\caches\modules-2\files-2.1\com.ongres.scram\client\1.0.0-beta.2\b6abad98aea51da5602d528ba3aa404f568db6bc\client-1.0.0-beta.2.xml was ignored from java classpath
JavaTestClasspath initialization (done) | time=94ms
----- Classpath analyzed by Squid:
C:\Users\usera\Documents\workspace\BBB\ProjectA\build\classes\java\main
C:\Users\usera\.gradle\caches\modules-2\files-2.1\org.projectlombok\lombok\1.16.16\245b50f714bf89ed7659266ace12f9e509d13551\lombok-1.16.16.jar
... Many more...
-----
----- Classpath analyzed by Squid:
C:\Users\usera\Documents\workspace\BBB\ProjectA\build\classes\java\test
C:\Users\usera\.gradle\caches\modules-2\files-2.1\org.projectlombok\lombok\1.16.16\245b50f714bf89ed7659266ace12f9e509d13551\lombok-1.16.16.jar
... Many more...
-----
Java Main Files AST scan
0 source files to be analyzed
Java Main Files AST scan (done) | time=0ms
Java Test Files AST scan
3 source files to be analyzed
0/0 source files have been analyzed
.class not found for java
.class not found for java.io
.class not found for java
.class not found for java.util
.class not found for java
.class not found for java.util
.class not found for java
.class not found for java.util
.class not found for junit
.class not found for junit.framework
.class not found for org
.class not found for org.junit
.class not found for org
.class not found for org.junit
.class not found for org.junit.runner
.class not found for org
.class not found for org.mockito
.class not found for org
.class not found for org.mockito
.class not found for org
.class not found for org.mockito
.class not found for org.mockito.runners
.class not found for org
.class not found for org.junit
.class not found for org
.class not found for org.junit
.class not found for org
.class not found for org.mockito
.class not found for org
.class not found for org.mockito
.class not found for org
.class not found for org.mockito
.class not found for org
.class not found for org.mockito
.class not found for org
.class not found for org.mockito
.class not found for com.co.AAA.BBB.ComponentA
.class not found for java.lang.package-info
.class not found for java.lang.uk
.class not found for java.lang.Synthetic$uk
.class not found for com.co
.class not found for com.co.AAA
.class not found for com.co.AAA.BBB
.class not found for com.co.AAA.BBB.ComponentA
.class not found for java
.class not found for java.math
.class not found for java
.class not found for java.util
.class not found for java
.class not found for java.util
.class not found for java
.class not found for java.util
.class not found for org
.class not found for org.junit
.class not found for org
.class not found for org.junit
.class not found for org
.class not found for org.mockito
.class not found for org
.class not found for org.mockito
.class not found for java.lang.package-info
.class not found for java.lang.Synthetic$Exception
.class not found for java.lang.uk
.class not found for java.lang.Synthetic$uk
.class not found for lombok
.class not found for org
.class not found for org.junit
.class not found for org
.class not found for org.mockito
.class not found for javax
.class not found for javax.swing
.class not found for java
.class not found for java.lang
.class not found for java.lang.reflect
.class not found for java
.class not found for java.util
.class not found for java
.class not found for java.util
.class not found for java
.class not found for java.util
.class not found for java.util.function
.class not found for junit
.class not found for junit.framework
.class not found for org
.class not found for org.mockito
.class not found for org
.class not found for org.mockito
.class not found for org
.class not found for org.mockito
.class not found for org
.class not found for org.mockito
Classes not found during the analysis : [javafx.scene.image.Image]
3/3 source files have been analyzed
Java Test Files AST scan (done) | time=887ms
Execute Sensor: SonarJavaXmlFileSensor
Done in 1285ms

Processed 0 issues in 652348 ms
Found 0 issues

Hi @mattjhussey

Thanks for providing already a lot of information with your question, that will certainly help.

A few missing information that may be interesting in your case are:

  • version of SonarLint for IntelliJ (I will assume you are using the latest)
  • version of SonarJava plugin installed on the SonarQube server you are binding to

Can you also precise the behavior that convince you that it works in standalone mode, but not in connected mode? Are you seeing some issues in one case, but not in the other?
In this case, please give us an example of such issue (what is important is the rule key of the issue, like squid:S1234).

Hi @Julien_HENRY

The version of SonarLint for IntelliJ I am using is v4.0.2.3009.
The version of SonarJava on SonarQube is v5.4 (build14284).

In Standalone mode I see thousands of issues while in connected mode I see none at all.
I also don’t see all of those “.class not found for java”, etc errors in Standalone mode.
Some examples are:

  • squid:S1192
  • squid:S00120
  • squid:S00115
  • squid:S1161
  • and many more.

Are you running IntelliJ with a JDK 11.

If yes, even if your project is targeting JDK 8, SonarJava will use the IDE runtime JDK to resolve some classes. This is a known issue:
https://jira.sonarsource.com/browse/SONARJAVA-3056

In the meantime, your best option is to request an update of SonarJava on your SonarQube server to at least 5.8, so that it supports properly JDK 11 bytecode:
https://jira.sonarsource.com/browse/SONARJAVA-2862

No. We are running JDK8 at the moment. JDK 11 is not installed.

Closing this thread due to lack of activity.

Feel free to open a new thread if you still have an issue/question.