Troubleshooting

Errors found on <sonar_root>/logs/sonar.log

max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]

If you are using systemd to start SonarQube, you must specify those limits inside your unit file in the section [service] :

/lib/systemd/system/sonar.service
[Service]
...
LimitNOFILE=65536
LimitNPROC=4096
...

And then reload services definitions and restart sonar service.

$ sudo systemctl daemon-reload
$ sudo service sonar restart

Otherwise, following files must be edited and limits must be assigned to 65536 (even though the message indicates 65535):

/etc/systemd/system.conf
...
DefaultLimitNOFILE=65536
...
/etc/systemd/user.conf
...
DefaultLimitNOFILE=65536
...
/etc/security/limits.conf
...
sonar                  - nofile  65536
sonar                  - nproc   4096
...

And reboot after changes are done!

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

Following files must be edited and set new max_map_count:

/etc/sysctl.conf
...
vm.max_map_count=262144
...

You can reload configuration with:

$ sudo sysctl -p

Errors found on <sonar_root>/logs/web.log

Execution of migration step #2506 'Migrate quality gate conditions using warning, period and no more supported operations' failed

This error can happen on updating to a new SonarQube version. First of all, go back to your previous version, restoring your database, and then do the following checks:

  1. Check if you have some error in your Quality Gates; if so, solve them before continue.
  2. Check if you have some error in your Quality Profiles; if so, solve them before continue.
  3. Check if there is a LTS version between your current version and the target version; if so, you have to upgrade first to the LTS. If there are more than one, you will have to upgrade to each LTS from lower to greater.
  4. After each upgrade, check again steps 1 and 2.

After thoses steps, you should be able to upgrade to your target version with no problem.

Errors found on "Quality profiles" section

Outdated copy

After an update you can find the following message for some profiles:

If you want to remove the outdated copy:

1. Open the engine on the right of the non-outdated copy, an select "Set as Default".

2. Open the engine on the right of the outdated copy, an select "Delete".

Console output messages

no protocol: null/objectscriptquality/license

ERROR: Error during SonarScanner execution
ERROR: Failed to execute project builder: com.objectscriptquality.license.client.LicenseChecker
ERROR: Caused by: unable to establish connection
ERROR: Caused by: no protocol: null/objectscriptquality/license?plugin_version=M.m.r

This error is given to a missing or wrong sonar.core.serverBaseUrl parameter in sonar-scanner.properties:

/opt/sonarqube/sonar-scanner/conf/sonar-scanner.properties
#Configure here general information about the environment, such as SonarQube DB details for example
#No information about specific project should appear here

#----- Default SonarQube server
# Following line must refer to the SonarQube installation, either if in localhost or not
sonar.core.serverBaseURL=http://localhost:9000

SonarScanner requires to connect to SonarQube to do some operations, like checking license or report analysis results.

Language of file 'MyFile.INC' can not be decided as the file matches patterns of both sonar.lang.patterns.objectscript : **/*.cls,**/*.mac,**/*.int,**/*.inc,**/*.ro and sonar.lang.patterns.php : **/*.php,**/*.php3,**/*.php4,**/*.php5,**/*.phtml,**/*.inc

This ig given that extension can be recognized by different languages. To avoid that situation, you have to sacrify the scan in some language. In that case, disable the PHP analyzer plugin during your analysis through the sonar.lang.patterns.php parameter:

$ /opt/sonarqube/sonar-scanner/bin/sonar-scanner \
    -Dsonar.lang.patterns.php="**/*.php" \
    -Dsonar.scanner.opts="--add-opens=java.base/java.lang=ALL-UNNAMED" \
    -Dsonar.projectKey="$JOB_NAME" \
    -Dsonar.projectName="$JOB_NAME" \
    -Dsonar.sources=. \
    -Dsonar.projectVersion=1.0

Remember to change versioned file to match your installation.

Unable to parse file

There are many reasons for this error, and probably you will need to contact us to explore why we cannot parse a file in your case. But a common reason is that the encoding of your source code and the encoding of the system where it is being analyzed, are different. Try to change the default encoding, add the encoding property

C:\sonarqube\sonar-{version}\conf\sonar.properties
. . .

# Source code encoding
sonar.objectscript.encode=UTF-8

. . .

java.desktop/sun.awt.FontConfiguration.getVersion

This is given to a missing library in system that is required by OpenJDK and usually happens on manual installation. Run following command to install the libfontconfig library:

$ apt install -y libfontconfig1 && rm -rf /var/lib/apt/lists/*

.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

You are probably using a server base URL different than localhost.

To solve the problem you have to install your server certificates on the Java KeyStore in the machine executing Jenkins and SonarQube.

 vm.max_map_count is too low

When executing on WSL2 on Windows, you can get the following message:

ERROR: [1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch.
bootstrap check failure [1] of [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
ERROR: Elasticsearch did not exit normally - check the logs at /opt/sonarqube/logs/sonarqube.log

You must increase your max_map_count directly in the linux subsystem shell with the following command:

# sysctl -w vm.max_map_count=262144