Analysis failed. org.sonar.java.AnalysisException: SonarQube is unable to analyze file

  • Versions tested: SonarLint 1.15.0 + VS Code 1.43.2
  • error observed:

Analyzing file ‘file:///c%3A/folder/path_to_file.java’…
Analysis failed. org.sonar.java.AnalysisException: SonarQube is unable to analyze file : ‘c:\folder\path_to_file.java’
at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:105)

I can’t make sonarlint work properly with my Java files in VS code. Any help would be appreciate :slight_smile:

I have doubled checked my configuration. Sonarlint works perfectly with my TypeScript and HTML files but not Java ones. Thanks

Hello, thanks for reporting this.

Could your please enable both “Show Analyzer Logs” and “Show Verbose Logs” (see FAQ) and paste any message / stack trace that arises? And if possible, could you please post relevant source code to reproduce the issue?

Also, support for Java in SonarLint requires version 0.56.0 of the Java Language extension, you might want to check that your extensions are up-to-date.

Hi Jean-Baptiste,
Thanks for your support.
This is a sample java file that fails (where xxx is my company and yyy my application):

package com.xxx.yyy.repository;
import org.springframework.stereotype.Repository;
import com.xxx.yyy.bo.homepage.HomepageNotification;
@Repository("homepageNotificationRepository")
public interface HomepageNotificationRepository extends PagingAndSortingRepository<HomepageNotification, String>{
}

This is a full stack for this file: https://pastebin.com/TZnVBcTy

The Language support for Java extension in my VS Code is version 0.59.0

Hey, thanks for the detailed report! I see in the analysis logs that you are using connected mode, which version of the Java analyzer is installed on the server side? This information should be logged when the SonarLint language server starts in VSCode, something like:

[Debug - 14:35:22.753] Starting connected SonarLint engine for 'connectionId'...
[Debug - 14:35:23.123] Create : /home/user/.sonarlint/plugins
[Debug - 14:35:23.124] Plugin cache: /home/user/.sonarlint/plugins
[Debug - 14:35:23.125] Create : /home/user/.sonarlint/plugins/_tmp
[Debug - 14:35:23.186] Load plugins
[Debug - 14:35:23.535] Load plugins (done) | time=349ms
[Debug - 14:35:23.733] Plugins:
[Debug - 14:35:23.734]   * SonarPython 2.4.0.5513 (python)
[Debug - 14:35:23.734]   * SonarJava 6.1.0.20866 (java)    <= Java version here
[Debug - 14:35:23.734]   * SonarHTML 3.2.0.2082 (web)
[Debug - 14:35:23.734]   * SonarPHP 3.3.0.5166 (php)
[Debug - 14:35:23.735]   * SonarTS 2.1.0.4445 (typescript)
[Debug - 14:35:23.735]   * SonarJS 6.3.0.12061 (javascript)
[Info  - 14:35:23.742] Using storage for server 'connectionId' (last update 29/01/2020 14:34)

Please make sure that your binding is up-to-date beforehand, using VSCode command “SonarLint: Update all project bindings to SonarQube/SonarCloud”.

Hi
this is the output of sonarlint start:

[Debug - 17:08:26.296] Default settings updated: WorkspaceFolderSettings[analyzerProperties={},testFilePattern=,connectionId=SonarQube,projectKey=APP_UI]
[Debug - 17:08:26.305] Starting connected SonarLint engine for 'SonarQube'...
[Debug - 17:08:27.881] Create : C:\Users\xxx\.sonarlint\plugins
[Debug - 17:08:27.882] Plugin cache: C:\Users\xxx\.sonarlint\plugins
[Debug - 17:08:27.883] Create : C:\Users\xxx\.sonarlint\plugins\_tmp
[Debug - 17:08:27.956] Load plugins
[Debug - 17:08:28.177] Load plugins (done) | time=220ms
[Debug - 17:08:28.396] Plugins:
[Debug - 17:08:28.397]   * License for SonarLint 7.7 (license)
[Debug - 17:08:28.397]   * SonarPython 1.13.0.2922 (python)
[Debug - 17:08:28.398]   * SonarJava 5.11.0.17289 (java)
[Debug - 17:08:28.398]   * SonarHTML 3.1.0.1615 (web)
[Debug - 17:08:28.398]   * SonarPHP 3.0.0.4537 (php)
[Debug - 17:08:28.399]   * SonarTS 1.9.0.3766 (typescript)
[Debug - 17:08:28.399]   * SonarApex 1.5.0.315 (sonarapex)
[Debug - 17:08:28.400]   * SonarJS 5.1.1.7506 (javascript)
[Debug - 17:08:28.400]   * SonarPLSQL 3.4.1.2576 (plsql)
[Info  - 17:08:28.410] Using storage for server 'SonarQube' (last update 26/03/20 16:43)

thanks again for your help

Hi @bnts43

I managed to reproduced and even found the root cause of the issue. I created a ticket so that we can fix the issue during the next sprint:
https://jira.sonarsource.com/browse/SLVSCODE-121

In the meantime, you can stop using connected mode, or update the Java analyzer on your SonarQube server to a more recent version (the one you are using is pretty old now).

Many thanks for reporting the issue!

Hi!
Great! Ouaw! What a fast fix it will be!
Thank you :slight_smile:
Actually, the version of SonarQube is managed by another team I don’t know.

I’ll wait for your fix then :wink:

Thanks again!