Access denied for Sonar database - sonarqube

I encounter an 'Access denied' error when connecting to the Sonar database. Below the trace:
[workspace] $ /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/Sonar/bin/sonar-runner -Dsonar.jdbc.driver=com.mysql.jdbc.Driver -Dsonar.jdbc.url=jdbc:mysql://tridev002.xxxxx.net:3306/sonar ******** ******** -Dsonar.host.url=http://tridev002.xxxx.net:9000/ ******** ******** "-Dsonar.projectBaseDir=/var/lib/jenkins/jobs/Test Sonar/workspace"
SonarQube Runner 2.4
Java 1.7.0_72 Oracle Corporation (64-bit)
Linux 3.2.0-4-amd64 amd64
INFO: Runner configuration file: /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/Sonar/conf/sonar-runner.properties
INFO: Project configuration file: NONE
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Work directory: /var/lib/jenkins/jobs/Test Sonar/workspace/.sonar
INFO: SonarQube Server 4.5.1
13:44:54.656 INFO - Load global referentials...
13:44:54.825 INFO - Load global referentials done: 173 ms
13:44:54.833 INFO - User cache: /var/lib/jenkins/.sonar/cache
13:44:54.841 INFO - Install plugins
13:44:54.920 INFO - Install JDBC driver
13:44:54.926 INFO - Create JDBC datasource for jdbc:mysql://tridev002.xxxxx.net:3306/sonar
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 1.494s
Final Memory: 8M/241M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: Fail to connect to database
ERROR: Caused by: Cannot create PoolableConnectionFactory (Access denied for user 'jenkins-sonar'#'tridev002.xxxxx.net' (using password: YES))
ERROR: Caused by: Access denied for user 'jenkins- sonar'#'tridev002.xxxxx.net' (using password: YES)
ERROR:
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
Build step 'Invoke Standalone Sonar Analysis' marked build as failure
In the Jenkins configuration the Database URL, Database login en Database password are set correctly. With this URL and credentials it is possible to log in via a mysql command line client and we can view the sonar database tables.
We also checked the permissions of the database user and these are set correctly.
We checked the sonar.properties file and everything is commented out.
If we add sonar.jdbc.username and sonar.jdbc.password to the project properties, the connection with the database is successfull. But the password is in plain text then, which is unadvisable.
Does anyone know why the credentials of the system configuration is not used? And what is the solution? Is this a bug in SonarQube?

Related

How to handle "Re-run SonarQube Scanner using the -X switch to enable full debug logging" Error

We've suddenly got the SonarQube Error on CI/CD pipeline, Concourse. Since we had no change around sonar properties recently, totally confused what this error requires us.
Preparing SonarQube scanner...
Starting sonar-scanner (type: cli)...
INFO: Scanner configuration file: /opt/sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: /tmp/build/put/sonar-input/sonar-project.properties
INFO: SonarQube Scanner 4.0.0.1744
INFO: Java 1.8.0_151 Oracle Corporation (64-bit)
INFO: Linux 4.15.0-159-generic amd64
INFO: User cache: /root/.sonar/cache
INFO: SonarQube server 7.9.1
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
WARN: SonarScanner will require Java 11+ to run starting in SonarQube 8.x
INFO: Sensor SurefireSensor [java] (done) | time=70ms
~
INFO: Sensor JavaXmlSensor [java]
INFO: Sensor JavaXmlSensor [java] (done) | time=3ms
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=14ms
INFO: ------------- Run sensors on project
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=4ms
INFO: Sensor Java CPD Block Indexer
INFO: Sensor Java CPD Block Indexer (done) | time=81ms
INFO: 55 files had no CPD blocks
INFO: Calculating CPD for 44 files
INFO: CPD calculation finished
INFO: Analysis report generated in 91ms, dir size=696 KB
INFO: Analysis report compressed in 319ms, zip size=316 KB
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 18.928s
INFO: Final Memory: 32M/995M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: The 'report' parameter is missing
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
ERROR in /opt/resource/out : line 251 with exit code 2
Is there any way to handle this error...?
And just wondering it would be clear this issue if we would reboot the sonarqube docker.
Any adivise would be highly appreciated.
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
968xxxxxxx5b bitnami/sonarqube:7.9.1 "/app-entrypoint.sh …" 9 months ago Up 8 months 0.0.0.0:80->9000/tcp docker_sonarqube_1
Thanks to following discussion, we understood that caused by the lack of disk spaces. After clean-up, it worked fine in our case.
Error: The ‘report’ parameter is missing
https://community.sonarsource.com/t/error-the-report-parameter-is-missing/9616
– Faced similar issue, and found disk space issue on the server. Once clearing the disk space it worked.
Sonarqube : The 'report' parameter is missing
https://stackoverflow.com/questions/48805695/sonarqube-the-report-parameter-is-missing
--I just had the same problem here: my Linux server ran out of disk space and Sonarqube started to produce the report parameter is missing error. After deleting some unused files and restarting sonarqube, everything worked normal again

Error during Sonar-runner execution, Fail to download libraries from server

I'm trying to install SonarQube Runner.
I am using this versions:
sonarqube-5.1
sonar-runner-dist-2.4
mysql 5.1.63
jdk 1.7.0_79
ubuntu 11.4, 32 bits
I've already configured:
sonar/conf/sonar.properties
sonar-runner/conf/sonar-runner.properties
And created the project configuration file to analyze, in the directory of my project:
sonar-project.properties
The SonarQube is running correctly, I can corroborate doing:
service sonar status
If I run:
sonar-runner -X
I get the following error:
SonarQube Runner 2.4
Java 1.7.0_79 Oracle Corporation (32-bit)
Linux 2.6.38-8-generic i386
INFO: Error stacktraces are turned on.
INFO: Runner configuration file: /opt/sonar-runner/conf/sonar-runner.properties
INFO: Project configuration file: /home/taller/taller2016/U3D_2016/sonar-project.properties
INFO: Default locale: "es_AR", source code encoding: "UTF-8"
INFO: Work directory: /home/taller/taller2016/U3D_2016/./.sonar
INFO: SonarQube Server 5.1
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 0.185s
Final Memory: 0M/53M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
java.lang.IllegalStateException: Fail to download libraries from server
at org.sonar.runner.impl.Jars.dowloadFiles(Jars.java:78)
at org.sonar.runner.impl.Jars.download(Jars.java:57)
at org.sonar.runner.impl.JarDownloader.download(JarDownloader.java:46)
at org.sonar.runner.impl.JarDownloader.checkVersionAndDownload(JarDownloader.java:37)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:71)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at org.sonar.runner.Main.executeTask(Main.java:70)
at org.sonar.runner.Main.execute(Main.java:59)
at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.io.IOException: Status returned by url : 'http://localhost:9002/sonar/batch_bootstrap/index' is invalid : 404
at org.sonar.runner.impl.ServerConnection.downloadString(ServerConnection.java:94)
at org.sonar.runner.impl.Jars.dowloadFiles(Jars.java:64)
... 12 more
What do I need to do or change to solve it?
The access.log contains:
127.0.0.1 - - [06/oct/2016:16:17:34 -0300] "GET /sonar/api/server/version HTTP/1.1" 200 3 "-" "SonarQubeRunner/2.4"
127.0.0.1 - - [06/oct/2016:16:17:34 -0300] "GET /sonar/batch_bootstrap/index HTTP/1.1" 302 109 "-" "SonarQubeRunner/2.4"
127.0.0.1 - - [06/oct/2016:16:17:34 -0300] "GET /sonar/api/maintenance HTTP/1.1" 404 1045 "-" "SonarQubeRunner/2.4"
Thanks!
I found that the version of Java that was running on the server was 6, and this SonarQube needs Java 7. So, I upgraded the version of java. Then continued giving other errors, but droping the database and regenerating it, it worked correctly.
In my case it was too old SonarQube scanner(runner) version. Update to 4.x should fix the problem. See also https://community.sonarsource.com/t/error-during-sonarqube-scanner-execution-after-upgrade-to-sonarqube-8/17378/2.

MSBuild.SonarQube.Runner.exe attempting to connect with h2 instead of SQL

The first 2 stages (prep, build) of an analysis from the command line with MSBuild.SonarQube.Runner.exe seem to work fine.
The properties in SonarQube.Analysis.xml are:
<Property Name="sonar.host.url">http://server-45:9000</Property>
<Property Name="sonar.login">admin</Property>
<Property Name="sonar.password">admin</Property>
<Property Name="sonar.jdbc.url">jdbc:jtds:sqlserver://server-46/SonarQube;instance=INSTANCE01;SelectMethod=Cursor</Property>
<Property Name="sonar.jdbc.driverClassName">com.microsoft.sqlserver.jdbc.SQLServerDriver</Property>
<Property Name="sonar.jdbc.username">sonarqube</Property>
<Property Name="sonar.jdbc.password">stackoverflow</Property>
The final stage fails with:
17:30:17.358 INFO - Create JDBC datasource for jdbc:h2:tcp://localhost/sonar
It appears to be ignoring the local xml settings file completely, finding the default one where the exe is which is identical and still trying to create a default h2 connection to a database.
Full log:
C:\Users\me\Documents\Visual Studio 2013\Projects\ClassLibrary9>MSBuild.SonarQube.Runner end
Default properties file was found at C:\Apps\MsSonarRunner\SonarQube.Analysis.xml
Loading analysis properties from C:\Apps\MsSonarRunner\SonarQube.Analysis.xml
Post-processing started.
WARNING: File is not under the project directory and cannot currently be analysed by SonarQube. File: C:\Users\me\AppData\Local\Temp\.NETFramework,Version=v4.5.AssemblyAttributes.cs, project: C:\Users\me\Documents\Visual Studio 2013\Projects\ClassLibrary9\ClassLibrary9\ClassLibrary9.csproj
The SONAR_RUNNER_HOME environment variable is not required and will be ignored.
SONAR_RUNNER_OPTS is not configured. Setting it to the default value of -Xmx1024m
Calling the sonar-runner...
C:\Users\me\Documents\Visual Studio 2013\Projects\ClassLibrary9\.sonarqube\bin\sonar-runner\bin\..
SonarQube Runner 2.4
Java 1.8.0_60 Oracle Corporation (64-bit)
Windows 8 6.2 amd64
SONAR_RUNNER_OPTS=-Xmx1024m
INFO: Error stacktraces are turned on.
INFO: Runner configuration file: C:\Users\me\Documents\Visual Studio 2013\Projects\ClassLibrary9\.sonarqube\bin\sonar-runner\bin\..\conf\sonar-runner.properties
INFO: Project configuration file: C:\Users\me\Documents\Visual Studio 2013\Projects\ClassLibrary9\.sonarqube\out\sonar-project.properties
INFO: Default locale: "en_GB", source code encoding: "UTF-8"
INFO: Work directory: C:\Users\me\Documents\Visual Studio 2013\Projects\ClassLibrary9\.sonarqube\out\.sonar
INFO: SonarQube Server 5.1.2
17:30:17.096 INFO - Load global repositories
17:30:17.295 INFO - Load global repositories (done) | time=200ms
17:30:17.296 INFO - Server id: 20151005162012
17:30:17.298 INFO - User cache: C:\Users\me\.sonar\cache
17:30:17.304 INFO - Install plugins
17:30:17.350 INFO - Install JDBC driver
17:30:17.358 INFO - Create JDBC datasource for jdbc:h2:tcp://localhost/sonar
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 0.817s
Final Memory: 8M/245M
INFO: ------------------------------------------------------------------------
17:30:17.415 Creating a summary markdown file...
Anyone any ideas here?
Thanks in advance.
Fixed.
This was a side effect of the following:
I copied batch files from another analysis over and the /s switch pointed to a completely different settings xml file. Doing the pre build run and the post build run with 2 different sets of settings causes this confusion.

sonar h2 Initializing Hibernate

Problem when run sonar with h2, why hibernate not init,so table could not be found:
INFO: SonarQube Server 5.0.1
10:27:11.403 INFO - Load global referentials...
10:27:11.586 INFO - Load global referentials done: 187 ms
10:27:11.591 INFO - User cache: D:\Project\.sonar\cache
10:27:11.605 INFO - Install plugins
10:27:11.976 INFO - Install JDBC driver
10:27:11.987 INFO - Create JDBC datasource for jdbc:h2:tcp://172.27.18.11:9091/sonar
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 2.660s
Final Memory: 2M/15M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by:
Error querying database. Cause: org.h2.jdbc.JdbcSQLException: Table "PROPERTIES" not found; SQL statement:
select p.id as id, p.prop_key as "key", p.text_value as value, p.resource_id as resourceId, p.user_id as userId
from properties p
where p.prop_key=?
AND p.resource_id is null*

Read timed out on /batch/project (SonarQube 4.5)

I am struggling with the following problem.
Log of the executed when sonar-runner in Jenkins.
SonarQube Runner 2.4
Java 1.7.0_67 Oracle Corporation (64-bit)
Windows 7 6.1 amd64
SONAR_RUNNER_OPTS=-Xms256m -Xmx512m
INFO: Runner configuration file: D:\CI_BUILD\sonar-runner-2.4\conf\sonar-runner.properties
INFO: Project configuration file: NONE
INFO: Default locale: "ko_KR", source code encoding: "UTF-8"
INFO: Work directory: D:\CI_BUILD\jenkins_home\jobs\CAFE-CLIENT\workspace\.sonar
INFO: SonarQube Server 4.5
05:17:52.119 INFO - Load global referentials...
05:17:53.382 INFO - Load global referentials done: 1263 ms
05:17:53.414 INFO - User cache: C:\Users\pcms_build\.sonar\cache
05:17:53.445 INFO - Install plugins
05:17:54.225 INFO - Install JDBC driver
05:17:54.303 INFO - Create JDBC datasource for jdbc:jtds:sqlserver://10.240.232.145/sonardb;SelectMethod=Cursor
05:17:56.222 INFO - Initializing Hibernate
05:17:59.217 INFO - Load project referentials...
05:18:19.232 INFO - Load project referentials done: 20015 ms
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 34.757s
Final Memory: 21M/291M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: Unable to request: /batch/project?key=CAFE-CLIENT&preview=false
ERROR: Caused by: Read timed out
ERROR:
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
Build step 'Invoke Standalone Sonar Analysis' marked build as failure
05:18:19.232 INFO - Load project referentials done: 20015 ms
When "Load project referentials done" value is larger than 20,000 ms,
Always "Read timed out" occurs.
Loading of project referentials is not expected to take more than a few seconds. It is very likely you have a performance issue on your SQ server (or with your DB). Here are some criteria that may increase duration of this web service:
you have installed a lot of language plugins or you have enabled a lot of rules in quality profiles
your project is a multi-module project with a lot of modules
Compare for example with:
http://nemo.sonarqube.org/batch/project?key=org.codehaus.sonar%3Asonar&preview=true
that returns more than 1000 rules and 33 modules. It takes less than 2 seconds to return data.
EDIT: it seems there was some SQL issues depending on your DB vendor. See http://jira.codehaus.org/browse/SONAR-5849 and http://jira.codehaus.org/browse/SONAR-6063. Should be fixed in upcoming 4.5.3

Resources