[SonarQube] Unable to scan a project locally

Hello all,

I’m evaluating SonarQube to check if it suits my company’s need, but I cannot scan our project.

I’m scanning with:

mvn sonar:sonar
-Dsonar.projectKey=…
-Dsonar.host.url=http://localhost:9000
-Dsonar.login=…

If I run this command with a project from github, it works; with this internal project, it doesn’t work.

It fails with an error:
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.2:sonar (default-cli) on project _______ Unable to execute SonarQube: Fail to download libraries from server -> [Help 1]

But I have no idea why, because mvn can build normally.

Interestingly, this stacktrace shows:

Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to execute SonarQube
at org.sonarsource.scanner.maven.bootstrap.ExceptionHandling.handle (ExceptionHandling.java:36)
at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute (ScannerBootstrapper.java:81)
at org.sonarsource.scanner.maven.SonarQubeMojo.execute (SonarQubeMojo.java:112)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)

Caused by: org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarQube
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run (IsolatedLauncherFactory.java:84)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run (IsolatedLauncherFactory.java:71)

Caused by: java.lang.IllegalStateException: Fail to download libraries from server
at org.sonarsource.scanner.api.internal.Jars.downloadFiles (Jars.java:93)
at org.sonarsource.scanner.api.internal.Jars.download (Jars.java:70)
at org.sonarsource.scanner.api.internal.JarDownloader.download (JarDownloader.java:39)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run (IsolatedLauncherFactory.java:75)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run (IsolatedLauncherFactory.java:71)

Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at org.sonarsource.scanner.api.internal.Jars.downloadFiles (Jars.java:87)
at org.sonarsource.scanner.api.internal.Jars.download (Jars.java:70)
at org.sonarsource.scanner.api.internal.JarDownloader.download (JarDownloader.java:39)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run (IsolatedLauncherFactory.java:75)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run (IsolatedLauncherFactory.java:71)
at java.security.AccessController.doPrivileged (Native Method)

My project is a multi-modules java application, built with maven. Our dependencies are managed by an internal artifact repository.
I’m running Sonar server (community edition - version 8.2 build 32929) through docker and using Java 1.8.0_221-b11.

Unfortunately, I got no extra information when tried to set flags like sonar.log.level/sonar.verbose.

Any help would be appreciated! :]
BR

Hey there.

The version of the SonarScanner for Maven is too old, you should use a newer version. :slight_smile:

mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar

:warning: If you’re evaluating SonarQube, is there a reason you aren’t using the latest version?

I was using this version of Sonar server because I was following the github guide about custom rules.

After your suggestion, I’ve updated to sonar-maven-plugin:3.7.0.1746 and server to 8.5.1 (build 38104), but I’m still facing some issue.

When I run the:

mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar
-Dsonar.projectKey=…
-Dsonar.host.url=http://localhost:9000
-Dsonar.login=…

Then, it fails with a message like:

[INFO] — sonar-maven-plugin:3.7.0.1746:sonar (default-cli) @ com.ericsson.bss.ael.aep.api —

[INFO] SonarQube version: 8.5.1
[INFO] Default locale: “en_US”, source code encoding: “UTF-8”
[INFO] Load global settings
[INFO] Load global settings (done) | time=127ms
[INFO] Server id: BF41A1F2-AXYUbhoOtyB3YoVlJW-N

[INFO] Load/download plugins
[INFO] Load plugins index
[INFO] Load plugins index (done) | time=100ms
[INFO] Load/download plugins (done) | time=285ms
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.815 s
[INFO] Finished at: 2020-11-30T17:52:57-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project ________: The preview mode, along with the ‘sonar.analysis.mode’ parameter, is no more supported. You should stop using this parameter. -> [Help 1]

For the sake of simplicity I did run this command in a small submodule.

What makes no sense to me, is that this module has no sonar.analysis.mode flag anywhere (this submodule doesn’t even declare Sonar as dependency; neither its parent).

Am I missing something?

Thanks for your help!
BR