Eclipse Che - SonarLint plugin not analyzing the java code

Team,
I am trying to integrate Sonarlint plug-in with Eclipse Che a browser based IDE for a Java project. I did add the SonarLint (sonarlint-vscode) and Java extension (vscode-xml) plugins and configured the SonarQube connections in the Workspace configuration to map the SonarQube server. I could see the connection is established between the editor and SonarQube server. While doing the code scan I get the below error. Can someone help to understand this further ? Initially I thought this is due to missing Java extension plugin but still I get the same.

[Debug - 12:07:32.175] Skipping analysis of Java file ‘file:///projects/Test-Project/Test-Project/src/main/java/com/suresh/test/BaseDao.java’ because SonarLint was unable to query project configuration (classpath, source level, …)

Hello, welcome to the community! And thank you for reporting this issue.

Which version of Eclipse Che are you using?

There was some work recently on Eclipse Che’s GitHub repository to support a fairly recent version of SonarLint (1.16, released early June). Following an issue opened in April, the sidecar container used by Che to run SonarLint was updated. According to GitHub, this fix was released as part of Eclipse Che’s 7.16.x release line.

Please also note that for Java analysis to work, SonarLint relies on an API provided by vscode-java (part of the standard Java extension pack); and for this API to be accessible, your project has to be fully imported in the IDE. With recent versions of vscode-java, this will be indicated by a ":+1: " icon in the lower right of the UI. In Eclipse Che, you will want to check that either “Language Support for Java 11” or “Language Support for Java 8” is installed and active in your workspace.

Thanks for supporting us. Here are the version details associated to my project.

Eclipse Che - 7.17.0-SNAPSHOT
Sonarlint - 1.16
Language Support for Java8 (including the extension pack through 0.63)

I use Java8 specific plugin since the development is happening through JDK1.8.
I could confirm Language Support for Java 8 is active and used in the project and
":+1: " icon is showing up as well.

Any further support is really helpful.

So I gave a try to Eclipse Che with SonarLint, following a short but accurate demo video to enable it on a multi module Maven project.

I did get a strange behavior: at initial startup, Java files triggered the same message as the one you posted (the “SonarLint was unable to query project configuration” one). However, once I closed and reopened the files, SonarLint was able to query project settings from the Java extension and to analyze them:

It looks like the first call happens at a time when the Java extension is not fully loaded (or the project not fully imported), and SonarLint does not get a well formed result.

I tried with the above approach and couldn’t succeeded. While doing further investigations I have come across Sonarlint for Visual Code is not displaying anything for Java after binding . In this it was mentioned “command”: “java.project.getClasspaths”, would get invoke but in my project I couldn’t see it in my Eclipse Che where as I could see it in my Visual Studio Code. Is there any project config or reference causing the issue I am into now.

Hello Suresh,

Could you try to open File > Settings > Open Preferences > SonarLint, and in the Output section could you tick the 2 options “Output Show Analyzer Logs” and “Output Show Verbose Logs”. You could then open the Output view, select the SonarLint entry in the dropdown list, then close and open a file. If you are able to send us the logs it might help us understand what is going on.

Thanks
Damien

Thanks Damien for the support. Here is the logs. Due to number of links restriction in this portal, i replaced my server name as myhost:port which uses http connection. So, please refer them as my SonarQube server.

Unable to locate TypeScript extension. TypeScript support in SonarLint might not work.
Executing /usr/lib/jvm/default-jvm/bin/java -jar /tmp/vscode-unpacked/sonarsource.sonarlint-vscode.latest.euazxqcslb.sonarlint-vscode-1.16.0.vsix/extension/server/sonarlint-ls.jar 35999 file:///tmp/vscode-unpacked/sonarsource.sonarlint-vscode.latest.euazxqcslb.sonarlint-vscode-1.16.0.vsix/extension/analyzers/sonarjava.jar file:///tmp/vscode-unpacked/sonarsource.sonarlint-vscode.latest.euazxqcslb.sonarlint-vscode-1.16.0.vsix/extension/analyzers/sonarjs.jar file:///tmp/vscode-unpacked/sonarsource.sonarlint-vscode.latest.euazxqcslb.sonarlint-vscode-1.16.0.vsix/extension/analyzers/sonarphp.jar file:///tmp/vscode-unpacked/sonarsource.sonarlint-vscode.latest.euazxqcslb.sonarlint-vscode-1.16.0.vsix/extension/analyzers/sonarpython.jar file:///tmp/vscode-unpacked/sonarsource.sonarlint-vscode.latest.euazxqcslb.sonarlint-vscode-1.16.0.vsix/extension/analyzers/sonarhtml.jar
[stdout] Binding to 35999
Child process connected on port 35999
[Debug - 14:08:40.154] Default settings updated: WorkspaceFolderSettings[analyzerProperties={},testFilePattern=,connectionId=poc_sonar,projectKey=GIT-AutoJobs]
[Debug - 14:08:40.703] Starting connected SonarLint engine for 'poc_sonar'...
[Debug - 14:08:41.215] Create : /home/theia/.sonarlint/plugins
[Debug - 14:08:41.215] Plugin cache: /home/theia/.sonarlint/plugins
[Debug - 14:08:41.215] Create : /home/theia/.sonarlint/plugins/_tmp
[Debug - 14:08:41.226] Load plugins
[Debug - 14:08:41.227] Load plugins (done) | time=1ms
[Debug - 14:08:41.247] No plugins loaded
[Warn  - 14:08:41.250] No storage for server 'poc_sonar'. Please update.
[Debug - 14:08:41.255] Connected SonarLint engine started for 'poc_sonar'
[Debug - 14:08:42.236] Create : /home/theia/.sonarlint/plugins
[Debug - 14:08:42.236] Plugin cache: /home/theia/.sonarlint/plugins
[Debug - 14:08:42.236] Create : /home/theia/.sonarlint/plugins/_tmp
[Debug - 14:08:42.362] GET 200 myhost:port/api/system/status | response time=123ms
[Debug - 14:08:42.409] Downloaded server infos in 170ms
[Debug - 14:08:42.518] GET 200 myhost:port/api/plugins/installed | response time=108ms
[Info  - 14:08:42.538] Downloaded plugin list in 128ms
[Debug - 14:08:42.590] GET 200 myhost:port/api/settings/values.protobuf | response time=25ms
[Info  - 14:08:42.649] Downloaded settings in 84ms
[Debug - 14:08:42.656] Code analyzer 'csharp' is not compatible with SonarLint. Skip downloading it.
[Debug - 14:08:42.656] Code analyzer 'scmgit' is not compatible with SonarLint. Skip downloading it.
[Debug - 14:08:42.656] Code analyzer 'jacoco' is not compatible with SonarLint. Skip downloading it.
[Debug - 14:08:42.658] Code analyzer 'cssfamily' is not compatible with SonarLint. Skip downloading it.
[Debug - 14:08:42.658] Code analyzer 'flex' is not compatible with SonarLint. Skip downloading it.
[Debug - 14:08:42.658] Code analyzer 'go' is not compatible with SonarLint. Skip downloading it.
[Debug - 14:08:42.658] Code analyzer 'kotlin' is not compatible with SonarLint. Skip downloading it.
[Debug - 14:08:42.658] Code analyzer 'ruby' is not compatible with SonarLint. Skip downloading it.
[Debug - 14:08:42.658] Code analyzer 'sonarscala' is not compatible with SonarLint. Skip downloading it.
[Debug - 14:08:42.658] Code analyzer 'xml' is not compatible with SonarLint. Skip downloading it.
[Debug - 14:08:42.659] Code analyzer 'scmsvn' is not compatible with SonarLint. Skip downloading it.
[Debug - 14:08:42.659] Code analyzer 'vbnet' is not compatible with SonarLint. Skip downloading it.
[Debug - 14:08:42.660] Download plugin 'sonar-java-plugin-6.5.1.22586.jar' to '/home/theia/.sonarlint/plugins/_tmp/13524844677171556729.tmp'...
[Debug - 14:08:42.690] GET 200 myhost:port/api/plugins/download?plugin=java | response time=27ms
[Info  - 14:08:42.886] Downloaded 'sonar-java-plugin-6.5.1.22586.jar' in 224ms
[Debug - 14:08:43.101] Create : /home/theia/.sonarlint/plugins/cfc8bbead33acae5a31c46399550df04
[Debug - 14:08:43.103] Download plugin 'java-custom-rules-1.26.jar' to '/home/theia/.sonarlint/plugins/_tmp/15039411299722708158.tmp'...
[Debug - 14:08:43.121] GET 200 myhost:port/api/plugins/download?plugin=javacustom | response time=17ms
[Info  - 14:08:43.386] Downloaded 'java-custom-rules-1.26.jar' in 282ms
[Debug - 14:08:43.539] Create : /home/theia/.sonarlint/plugins/78505c0ae191c7a590578fe13f5faad8
[Debug - 14:08:43.539] Download plugin 'sonar-php-plugin-3.5.0.5655.jar' to '/home/theia/.sonarlint/plugins/_tmp/2543377026699714769.tmp'...
[Debug - 14:08:43.558] GET 200 myhost:port/api/plugins/download?plugin=php | response time=19ms
[Info  - 14:08:43.646] Downloaded 'sonar-php-plugin-3.5.0.5655.jar' in 107ms
[Debug - 14:08:43.732] Create : /home/theia/.sonarlint/plugins/7820eb80fb9db77a649080050bb492e5
[Debug - 14:08:43.733] Download plugin 'sonar-python-plugin-2.13.0.7236.jar' to '/home/theia/.sonarlint/plugins/_tmp/2078533300210830157.tmp'...
[Debug - 14:08:43.753] GET 200 myhost:port/api/plugins/download?plugin=python | response time=20ms
[Info  - 14:08:43.796] Downloaded 'sonar-python-plugin-2.13.0.7236.jar' in 63ms
[Debug - 14:08:43.825] Create : /home/theia/.sonarlint/plugins/a85d40b83e81dc84a069ff270da9877c
[Debug - 14:08:43.826] Download plugin 'sonar-html-plugin-3.2.0.2082.jar' to '/home/theia/.sonarlint/plugins/_tmp/14274084883885717438.tmp'...
[Debug - 14:08:43.843] GET 200 myhost:port/api/plugins/download?plugin=web | response time=16ms
[Info  - 14:08:43.850] Downloaded 'sonar-html-plugin-3.2.0.2082.jar' in 24ms
[Debug - 14:08:43.855] Create : /home/theia/.sonarlint/plugins/298a75a167830bfe6c1a75bf3a08fe19
[Debug - 14:08:43.856] Download plugin 'sonar-javascript-plugin-6.2.1.12157.jar' to '/home/theia/.sonarlint/plugins/_tmp/8784539960301062244.tmp'...
[Debug - 14:08:43.873] GET 200 myhost:port/api/plugins/download?plugin=javascript | response time=17ms
[Info  - 14:08:43.958] Downloaded 'sonar-javascript-plugin-6.2.1.12157.jar' in 102ms
[Debug - 14:08:44.029] Create : /home/theia/.sonarlint/plugins/52f5340dd05620cd162e2b9a45a57124
[Debug - 14:08:44.029] Download plugin 'sonar-typescript-plugin-2.1.0.4359.jar' to '/home/theia/.sonarlint/plugins/_tmp/2654423213210475098.tmp'...
[Debug - 14:08:44.076] GET 200 myhost:port/api/plugins/download?plugin=typescript | response time=47ms
[Info  - 14:08:44.076] Downloaded 'sonar-typescript-plugin-2.1.0.4359.jar' in 47ms
[Debug - 14:08:44.077] Create : /home/theia/.sonarlint/plugins/1b0c24e5d9a55450dfadcd0a2c8bc5c8
[Debug - 14:08:44.116] GET 200 myhost:port/api/rules/search.protobuf?f=repo,name,severity,lang,htmlDesc,htmlNote,internalKey,isTemplate,templateKey,actives&statuses=BETA,DEPRECATED,READY&types=CODE_SMELL,BUG,VULNERABILITY&severities=INFO&p=1&ps=500 | response time=36ms
[Debug - 14:08:44.488] GET 200 myhost:port/api/rules/search.protobuf?f=repo,name,severity,lang,htmlDesc,htmlNote,internalKey,isTemplate,templateKey,actives&statuses=BETA,DEPRECATED,READY&types=CODE_SMELL,BUG,VULNERABILITY&severities=MINOR&p=1&ps=500 | response time=130ms
[Debug - 14:08:44.648] GET 200 myhost:port/api/rules/search.protobuf?f=repo,name,severity,lang,htmlDesc,htmlNote,internalKey,isTemplate,templateKey,actives&statuses=BETA,DEPRECATED,READY&types=CODE_SMELL,BUG,VULNERABILITY&severities=MINOR&p=2&ps=500 | response time=90ms
[Debug - 14:08:44.805] GET 200 myhost:port/api/rules/search.protobuf?f=repo,name,severity,lang,htmlDesc,htmlNote,internalKey,isTemplate,templateKey,actives&statuses=BETA,DEPRECATED,READY&types=CODE_SMELL,BUG,VULNERABILITY&severities=MAJOR&p=1&ps=500 | response time=114ms
[Debug - 14:08:44.979] GET 200 myhost:port/api/rules/search.protobuf?f=repo,name,severity,lang,htmlDesc,htmlNote,internalKey,isTemplate,templateKey,actives&statuses=BETA,DEPRECATED,READY&types=CODE_SMELL,BUG,VULNERABILITY&severities=MAJOR&p=2&ps=500 | response time=131ms
[Debug - 14:08:45.045] GET 200 myhost:port/api/rules/search.protobuf?f=repo,name,severity,lang,htmlDesc,htmlNote,internalKey,isTemplate,templateKey,actives&statuses=BETA,DEPRECATED,READY&types=CODE_SMELL,BUG,VULNERABILITY&severities=MAJOR&p=3&ps=500 | response time=40ms
[Debug - 14:08:45.155] GET 200 myhost:port/api/rules/search.protobuf?f=repo,name,severity,lang,htmlDesc,htmlNote,internalKey,isTemplate,templateKey,actives&statuses=BETA,DEPRECATED,READY&types=CODE_SMELL,BUG,VULNERABILITY&severities=CRITICAL&p=1&ps=500 | response time=98ms
[Debug - 14:08:45.232] GET 200 myhost:port/api/rules/search.protobuf?f=repo,name,severity,lang,htmlDesc,htmlNote,internalKey,isTemplate,templateKey,actives&statuses=BETA,DEPRECATED,READY&types=CODE_SMELL,BUG,VULNERABILITY&severities=BLOCKER&p=1&ps=500 | response time=61ms
[Debug - 14:08:45.424] GET 200 myhost:port/api/qualityprofiles/search.protobuf | response time=46ms
[Debug - 14:08:45.448] Downloaded quality profiles in 68ms
[Debug - 14:08:45.480] GET 200 myhost:port/api/components/search.protobuf?qualifiers=TRK&ps=500&p=1 | response time=15ms
[Debug - 14:08:45.486] Page downloaded in 21ms
[Debug - 14:08:45.502] Create : /home/theia/.sonarlint/plugins
[Debug - 14:08:45.503] Plugin cache: /home/theia/.sonarlint/plugins
[Debug - 14:08:45.503] Create : /home/theia/.sonarlint/plugins/_tmp
[Debug - 14:08:45.504] Load plugins
[Debug - 14:08:45.548] Load plugins (done) | time=44ms
[Debug - 14:08:45.833] Plugins:
[Debug - 14:08:45.834]   * Python Code Quality and Security 2.13.0.7236 (python)
[Debug - 14:08:45.834]   * Java Code Quality and Security 6.5.1.22586 (java)
[Debug - 14:08:45.834]   * SonarHTML 3.2.0.2082 (web)
[Debug - 14:08:45.834]   * Java Custom Rules 1.26 (javacustom)
[Debug - 14:08:45.834]   * PHP Code Quality and Security 3.5.0.5655 (php)
[Debug - 14:08:45.834]   * SonarTS 2.1.0.4359 (typescript)
[Debug - 14:08:45.834]   * SonarJS 6.2.1.12157 (javascript)
[Info  - 14:08:45.837] Using storage for server 'poc_sonar' (last update 8/13/20, 2:08 PM)
[Info  - 14:08:46.154] Global storage status: org.sonarsource.sonarlint.core.container.model.DefaultGlobalStorageStatus@7d1587c3
[Debug - 14:08:46.222] GET 200 myhost:port/api/qualityprofiles/search.protobuf?project=GIT-AutoJobs | response time=55ms
[Debug - 14:08:46.222] Downloaded project quality profiles in 55ms
[Debug - 14:08:46.252] GET 200 myhost:port/api/settings/values.protobuf?component=GIT-AutoJobs | response time=29ms
[Info  - 14:08:46.259] Downloaded settings in 36ms
[Debug - 14:08:46.276] GET 200 myhost:port/api/components/tree.protobuf?qualifiers=BRC&component=GIT-AutoJobs&ps=500&p=1 | response time=15ms
[Debug - 14:08:46.277] Page downloaded in 16ms
[Debug - 14:08:46.330] GET 200 myhost:port/batch/issues?key=GIT-AutoJobs | response time=43ms
[Debug - 14:08:46.366] Downloaded issues in 79ms
[Debug - 14:08:46.535] GET 200 myhost:port/api/components/tree.protobuf?qualifiers=FIL,UTS&component=GIT-AutoJobs&ps=500&p=1 | response time=59ms
[Debug - 14:08:46.536] Page downloaded in 60ms
[Debug - 14:08:46.585] Resolved binding ProjectBinding[projectKey=GIT-AutoJobs,sqPathPrefix=,idePathPrefix=AutoJobs] for folder /projects
[Debug - 14:09:23.321] Cached Java config for file 'file:///projects/AutoJobs/AutoJobs/src/main/java/com/mypoc/myproject/autojob/dao/BaseDao.java'
[Debug - 14:09:23.322] Skipping analysis of Java file 'file:///projects/AutoJobs/AutoJobs/src/main/java/com/mypoc/myproject/autojob/dao/BaseDao.java' because SonarLint was unable to query project configuration (classpath, source level, ...)
[Debug - 14:09:36.870] File 'file:///projects/AutoJobs/AutoJobs/src/main/java/com/mypoc/myproject/autojob/dao/BaseDao.java' closed. Cleaning diagnostics.
[Debug - 14:09:43.155] Queuing analysis of file 'file:///projects/AutoJobs/AutoJobs/src/main/java/com/mypoc/myproject/autojob/dao/BaseDao.java'
[Warn  - 14:10:43.156] Unable to get Java config
[Warn  - 14:10:43.157] java.util.concurrent.TimeoutException
	at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1886)
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2021)
	at org.sonarsource.sonarlint.ls.AnalysisManager.getJavaConfigFromCacheOrFetch(AnalysisManager.java:269)
	at org.sonarsource.sonarlint.ls.AnalysisManager.analyze(AnalysisManager.java:209)
	at org.sonarsource.sonarlint.ls.AnalysisManager.lambda$analyzeAsync$0(AnalysisManager.java:205)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)

[Debug - 14:10:43.157] Skipping analysis of Java file 'file:///projects/AutoJobs/AutoJobs/src/main/java/com/mypoc/myproject/autojob/dao/BaseDao.java' because SonarLint was unable to query project configuration (classpath, source level, ...)

Hello Suresh,

Do you use the cloud version of Eclipse Che ? Would you be able to share with us your Devfile ? If it points to a private repo you can remove the URL.

I get an error when I try with the default ‘Java Maven’ workspace and I activate Java 8 support and SonarLint. But it’s not the same error as what you get. I think we would need more time to investigate and provide a fix.

In the meantime I think we need to clarify that we don’t officially support Eclipse Che. This plugin version is provided by the Eclipse Che team, we don’t actively maintain and test it, at least for the moment, so we can’t say we are confident with the way it works today. In theory VSCode extensions are supposed to work within the platform, but as you can see we might need to make adjustments for the plugin to work reliably. We need to discuss internally about how we should handle this.

We will come back to you as soon as we can.

Thanks
Damien

Thanks again Damien. Yes, we were also under the impression of VSCode extensions supposed to work since Che’s documentation mentioning it. It would be a great support if you can help in resolving the issue we are into now. Do you suggest to make use of SonarLint plugin which is outside to Che’s default library ? Please refer the below dev file.

metadata:
  name: poc-autojobs-jdk8
projects:
  - name: AutoJobs
    source:
      location: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
      type: git
      branch: master
components:
  - mountSources: true
    memoryLimit: 512Mi
    type: dockerimage
    volumes:
      - name: gradle
        containerPath: /home/gradle/.gradle
    alias: gradle
    image: 'XX.X.XX.XXX:5000/gradlejdk8:latest'
  - id: redhat/java8/latest
    type: chePlugin
  - id: sonarsource/sonarlint-vscode/latest
    type: chePlugin
apiVersion: 1.0.0
commands:
  - name: buildApp
    actions:
      - workdir: '${CHE_PROJECTS_ROOT}/AutoJobs/AutoJobs'
        type: exec
        command: gradle -b build_wl.gradle clean  build
        component: gradle
  - name: runApp
    actions:
      - workdir: '${CHE_PROJECTS_ROOT}/AutoJobs/AutoJobs/build/libs'
        type: exec
        command: java -jar AutoJobs.war
        component: gradle

In fact I missed to respond about my Eclipse Che. It is not a cloud version and the same is hosted on our premises.

Hello, thank you for the devfile.yml.

I see in the log extract you posted that the getConfig request times out after one minute.

This is not expected, unless your project is fairly large / has a large number of dependencies.

I would be curious to see how much time the Java Language Support extension takes to answer. In my tests with a (small) Maven project, I got this:

[Trace - 10:18:40 AM] Sending request 'workspace/executeCommand - (132)'.
Params: {
    "command": "java.project.getSettings",
    "arguments": [
        "file:///projects/CodeStoryStep2/src/main/java/fr/xebia/katas/gildedrose/Item.java",
        [
            "org.eclipse.jdt.core.compiler.compliance"
        ]
    ]
}


[Trace - 10:18:40 AM] Received response 'workspace/executeCommand - (132)' in 2ms.
Result: {
    "org.eclipse.jdt.core.compiler.compliance": "1.6"
}

Could you please enable verbose logging for the Java language server and look for this kind of trace in its output?

This is done with the following workspace settings in .theia/settings.json:

{
    "java.trace.server": "verbose"
}

Thanks Team for the continuous support. Please find the below specific details as you requested after enabling the verbose in Java Language Support.

[Trace - 8:11:32 AM] Sending request ‘workspace/executeCommand - (4)’.
Params: {
“command”: “java.project.getSettings”,
“arguments”: [
“file:///projects/AutoJobs/AutoJobs/”,
[
“org.eclipse.jdt.core.compiler.source”,
“org.eclipse.jdt.ls.core.vm.location”
]
]
}

[Trace - 8:11:32 AM] Received response ‘workspace/executeCommand - (4)’ in 68ms.
Result: {
“org.eclipse.jdt.core.compiler.source”: “1.8”,
“org.eclipse.jdt.ls.core.vm.location”: “/usr/lib/jvm/java-1.8-openjdk”
}

Team, do we have any update on this one ?

Hello Suresh,

As we said there is a timeout when trying to reach the Java extension to get the classpath. It seems that our extension is not able to communicate with other ones. We suspect this is by design, as extensions seem to be containerized in Eclipse Che.

We are still discussing internally about what our position should be regarding Eclipse Che. In the meantime I encourage you to directly get in touch with the maintainers of Eclipse Che to move this issue forward, as anyway it looks like there is not much we could do on our side for the time being.

Thanks for the continuous feedback you gave us

Damien