# Error in java code analysis with sonar-scanner

**URL:** <https://community.sonarsource.com/t/error-in-java-code-analysis-with-sonar-scanner/34433>\
**Category:** SonarQube Server / Community Build\
**Tags:** sonarqube, java, scanner\
**Created:** [November 13, 2020, 2:54am UTC](https://community.sonarsource.com/t/error-in-java-code-analysis-with-sonar-scanner/34433 "2020-11-13T02:54:51Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jorge\_Lino](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jorge_lino/32/2170_2.png) [@Jorge\_Lino](https://community.sonarsource.com/u/Jorge_Lino)\
**Post date:** [November 13, 2020, 2:54am UTC](https://community.sonarsource.com/t/error-in-java-code-analysis-with-sonar-scanner/34433/1 "2020-11-13T02:54:51Z")

</div>

Goodnight.  
Currently I have in the code analysis of 2 projects developed in JAVA:  
1.- In the first project the analysis is made locally and at the end of the analysis the TIME OUT error message is displayed. Attached file (project # 1)  
2.- In the second project, the analysis is also done locally with the sonarscanner but at the time of presenting the results on the main page of the SonarQube, only the analysis of a single language (xml) is presented, when the project is developed in java and xml. Attached file (project # 2)

The SonarQube version used is Enterprise Edition Version 7.9.1 (build 27448) with sonar-scanner-3.2.0.1227  
Java projects are developed in Java Eclipse Oxygen  
[project#1.txt](https://community.sonarsource.com/uploads/short-url/kF6rjXPULIE45elZcaAo3iTluq7.txt) (34.7 KB) [project#2.txt](https://community.sonarsource.com/uploads/short-url/loM7iFM1rqMedRXVCTTuiNSYkUi.txt) (31.5 KB)

---

<div class="post-metadata">

**Author:** ![Joe](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/joe/32/14820_2.png) [@Joe](https://community.sonarsource.com/u/Joe)\
**Post date:** [November 13, 2020, 5:42am UTC](https://community.sonarsource.com/t/error-in-java-code-analysis-with-sonar-scanner/34433/2 "2020-11-13T05:42:57Z")

</div>

Hi @Jorge_Lino,

Regarding your project #1, here’s my understanding:

- As you noticed, the scan fails because the SonarScanner is unable to “blame” the source file to know which lines were changed because connectivity to your SVN does not seem to work.
- Quick workaround is to disable SCM integration by passing in this parameter `-D"sonar.scm.disabled=true"`. You’ll lose the metadata (date, author of commits, etc.) related to the file but it will get your analysis to continue.
- To truly fix this issue, you need to figure out why SonarQube cannot access your SVN. You should check the Administration \> General Settings \> SCM \> SVN section settings.

Regarding project #2:

- I cannot easily tell why the Java file is not being analyzed nor recognized in your logs.

Here is my recommendation:

- Update all of the SonarSource core plugins (the ones that say “Developed by SonarSource”) in the Administration \> Marketplace, check that you have the latest versions with the [Plugin Version Matrix](https://docs.sonarqube.org/latest/instance-administration/plugin-version-matrix/)
- Instead of using the sonar-scanner CLI for your Java projects, you should use [SonarScanner for Gradle](https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-gradle/) or [Maven](https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-maven/). These SonarScanner wrappers are very similar to the sonar-scanner CLI, but they handle the parameters for `sonar.java.binaries`, `sonar.sources`, etc. without you having to set them. Check out the [sonar-scanning-examples](https://github.com/SonarSource/sonar-scanning-examples) repo with examples of how the projects and files are structured.

Once you update your plugins, try running your `sonar-scanner` command again and see if you get the same errors. Has this every worked before? If it hasn’t, please try using SonarScanner for Gradle or Maven and scan again. If it fails, please provide the debug logs.

- For Gradle, you can pass it inline: `./gradlew clean build sonarqube --debug`
- For Maven, you can pass it inline as well: `./mvn clean install sonar:sonar -X`

Joe

---

<div class="post-metadata">

**Author:** ![Jorge\_Lino](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jorge_lino/32/2170_2.png) [@Jorge\_Lino](https://community.sonarsource.com/u/Jorge_Lino)\
**Post date:** [November 16, 2020, 11:23pm UTC](https://community.sonarsource.com/t/error-in-java-code-analysis-with-sonar-scanner/34433/3 "2020-11-16T23:23:19Z")

</div>

Thanks Joe.  
I comment:  
The solution from the first project worked, now both projects (project # 1 and project # 2) have the same problem. I tried the recommendation you gave me for project # 2 it didn’t work.

---

<div class="post-metadata">

**Author:** ![Joe](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/joe/32/14820_2.png) [@Joe](https://community.sonarsource.com/u/Joe)\
**Post date:** [November 18, 2020, 8:41pm UTC](https://community.sonarsource.com/t/error-in-java-code-analysis-with-sonar-scanner/34433/4 "2020-11-18T20:41:42Z")

</div>

Hi @Jorge_Lino,

> [@Jorge\_Lino](#):
>
> The solution from the first project worked, now both projects (project # 1 and project # 2) have the same problem.

Good: now we can proceed with focusing on a single issue now.

Please pass `-D"sonar.verbose=true"`, rerun your scan analysis, and please attach the logs again.

Joe

---

<div class="post-metadata">

**Author:** ![Jorge\_Lino](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jorge_lino/32/2170_2.png) [@Jorge\_Lino](https://community.sonarsource.com/u/Jorge_Lino)\
**Post date:** [November 24, 2020, 12:47am UTC](https://community.sonarsource.com/t/error-in-java-code-analysis-with-sonar-scanner/34433/6 "2020-11-24T00:47:39Z")

</div>

Hi, Joe  
I send you the requested files  
thanks  
[project#1\_2311.txt](https://community.sonarsource.com/uploads/short-url/yLTfp5QxnTD20qyGJIjmRilZfR6.txt) (31.0 KB) [project#2\_2311.txt](https://community.sonarsource.com/uploads/short-url/n3Z7bjeNhybf5p45rRxChMpxOR0.txt) (31.4 KB)

---

<div class="post-metadata">

**Author:** ![Joe](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/joe/32/14820_2.png) [@Joe](https://community.sonarsource.com/u/Joe)\
**Post date:** [November 24, 2020, 6:30am UTC](https://community.sonarsource.com/t/error-in-java-code-analysis-with-sonar-scanner/34433/7 "2020-11-24T06:30:15Z")

</div>

Hi @Jorge_Lino,

Thank you for updated logs. I still cannot see why the Java file is being ignored since it looks correct so far.

Can you provide a reproducer for me? It can be the entire Java project you have or just the files needed to recreate the problem, whichever is easier.

Joe

---

<div class="post-metadata">

**Author:** ![Jorge\_Lino](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jorge_lino/32/2170_2.png) [@Jorge\_Lino](https://community.sonarsource.com/u/Jorge_Lino)\
**Post date:** [November 30, 2020, 2:24am UTC](https://community.sonarsource.com/t/error-in-java-code-analysis-with-sonar-scanner/34433/8 "2020-11-30T02:24:18Z")

</div>

For reasons of company policy, I could not provide you with the java project or a video performing the analysis.  
Does the .sonarscanner file that is generated in the analysis of the projects help you?  
In any case, we spoke with the person who is executing the analysis and in the course of this week the analysis will be carried out on another machine to download that it is a computer problem.

---

<div class="post-metadata">

**Author:** ![Joe](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/joe/32/14820_2.png) [@Joe](https://community.sonarsource.com/u/Joe)\
**Post date:** [December 8, 2020, 10:51pm UTC](https://community.sonarsource.com/t/error-in-java-code-analysis-with-sonar-scanner/34433/9 "2020-12-08T22:51:50Z")

</div>

@Jorge_Lino, thank you for the update. Can you confirm that the issue was a computer issue and the analysis now works on another computer?

One thing I forgot to suggest: add an exclusion for the .scannerwork folder in your project or the entire project in your antivirus software. Since you are on Windows, you may be using Windows defender or something like that. This may help prevent strange issues like what you encountered.

Joe

---

<div class="post-metadata">

**Author:** ![Jorge\_Lino](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jorge_lino/32/2170_2.png) [@Jorge\_Lino](https://community.sonarsource.com/u/Jorge_Lino)\
**Post date:** [December 14, 2020, 11:13pm UTC](https://community.sonarsource.com/t/error-in-java-code-analysis-with-sonar-scanner/34433/10 "2020-12-14T23:13:45Z")

</div>

Hi Joe  
I did the analysis on the other computer and it gave me the same problem; The strange thing about all this is that only those two projects have these problems, the others are fine (more than 100 projects analyzed)

---

<div class="post-metadata">

**Author:** ![Joe](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/joe/32/14820_2.png) [@Joe](https://community.sonarsource.com/u/Joe)\
**Post date:** [December 17, 2020, 4:57am UTC](https://community.sonarsource.com/t/error-in-java-code-analysis-with-sonar-scanner/34433/11 "2020-12-17T04:57:16Z")

</div>

Very strange, @Jorge_Lino. Those 2 projects are problematic for strange reasons. Can you confirm that you’ve updated all your plugins, especially SonarJava? Also, did you switch to a Gradle/Maven build tool so that you can use Sonar Scanner for Gradle/Maven instead of the plain Sonar Scanner CLI? Even if the conversion to Gradle/Maven didn’t work, this should be the preferred way, if there is no other reason, when scanning a Java project.

Let me suggest a few ideas:

1. Create a whole new project since its just 2 files and just start all over. Don’t copy and paste any of those files. Start fresh.
2. Create a whole new project and copy and paste the files into this new project.
3. Repeat both of these suggestions on someone else’s computer then try scanning on your computer.

Joe
