sonar-runner fails every time - sonarqube

While running sonar-runner (with debug flags, and stack trace) I'm getting an error.
My sonar server is bound to mysql which runs on the same machine. It was running ok for some time, but lately it have started ending with following error.
10:25:23.030 DEBUG - 178223 measures to dump
10:25:23.629 DEBUG - Updating semaphore batch-test:test1
10:25:33.739 DEBUG - Updating semaphore batch-test:test1
10:25:43.968 DEBUG - Updating semaphore batch-test:test1
10:25:49.551 INFO - Store results in database
10:25:49.551 DEBUG - Execute org.sonar.batch.index.ComponentDataPersister
10:25:54.151 DEBUG - Updating semaphore batch-test:test1
10:26:02.159 DEBUG - Execute org.sonar.batch.issue.IssuePersister
10:26:02.196 DEBUG - ooo Using Connection [jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8, UserName=sonar#localhost, MySQL Connector Java]
10:26:02.196 DEBUG - ==> Preparing: select * from projects p WHERE p.kee=?
10:26:02.196 DEBUG - ==> Parameters: test:test1:com.test.framework.gba.GbaInfoProvider(String)
10:26:02.198 DEBUG - Release semaphore on project : org.sonar.api.resources.Project#45de530a[id=2644,key=test:test1,qualifier=TRK], with key batch-test:test1
10:26:02.281 DEBUG - To prevent a memory leak, the JDBC Driver [com.mysql.jdbc.Driver] has been forcibly deregistered
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 27:30.454s
Final Memory: 27M/872M
Any ideas why it fails?

Related

SonarQube 5.3 stopped analyzing Github pull requests

We have recently updated our SonarQube version from 5.0 to 5.3 and our SonarQube Scanner/Runner from 2.3 to 2.4.
During this upgrade, SonarQube has stopped analyzing our GitHub pull requests. We run the SonarQube Scanner as the last step in our jenkins job.
The command we run is as follows:
/usr/local/sonar-runner/bin/sonar-runner -Dsonar.analysis.mode=issues \
-Dsonar.github.pullRequest=${ghprbPullId} \
-Dsonar.github.repository=OurRepository/OurRepository \
-Dsonar.github.login=MyUsername \
-Dsonar.github.oauth=MyToken \
-Dsonar.login=MyUsername \
-Dsonar.password=MyPassword \
-Dsonar.sources=./app/ \
-Dsonar.projectKey=MyProject \
-Dsonar.projectName=MyProject \
-Dsonar.projectVersion=2.9.0 \
-Dsonar.exclusions=app/Vendor/**,app/Plugin/**/Test/**,app/Test/**
The only thing we changed during this upgrade is the analysis mode. Before the upgrade we used the incremental mode which has been removed in 5.2.
The output of the command is as follows:
+ /usr/local/sonar-runner/bin/sonar-runner -Dsonar.analysis.mode=issues -Dsonar.github.pullRequest=2944 -Dsonar.github.repository=OurRepository/OurRepository -Dsonar.github.login=Username -Dsonar.github.oauth=MyToken -Dsonar.login=MyUsername -Dsonar.password=MyPAsword -Dsonar.sources=./app/ -Dsonar.projectKey=MyProject -Dsonar.projectName=MyProject -Dsonar.projectVersion=2.9.0 '-Dsonar.exclusions=app/Vendor/**,app/Plugin/**/Test/**,app/Test/**'
SonarQube Runner 2.4
Java 1.7.0_101 Oracle Corporation (64-bit)
Linux 3.10.0-327.13.1.el7.x86_64 amd64
INFO: Runner configuration file: /usr/local/sonar-runner/conf/sonar-runner.properties
INFO: Project configuration file: /projectpath/sonar-project.properties
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Work directory: /projectpath/./.sonar
INFO: SonarQube Server 5.3
12:54:00.422 INFO - Load global repositories
12:54:00.927 INFO - Load global repositories (done) | time=505ms
12:54:00.988 INFO - User cache: /projectpath/.sonar/cache
12:54:01.016 INFO - Exclude plugins: devcockpit, jira, pdfreport, views, report, buildstability, buildbreaker, scmstats
12:54:01.417 INFO - Load plugins index
12:54:01.431 INFO - Load plugins index (done) | time=14ms
12:54:02.121 INFO - Found project [MyProject] cache [Thu May 19 11:29:15 CEST 2016]
12:54:02.280 INFO - Process project properties
12:54:02.723 INFO - Load project repositories
12:54:03.461 INFO - Load project repositories (done) | time=738ms
12:54:03.485 INFO - Apply project exclusions
12:54:03.629 INFO - Load quality profiles
12:54:04.348 INFO - Load quality profiles (done) | time=719ms
12:54:04.357 INFO - Load active rules
12:54:09.383 INFO - Load active rules (done) | time=5026ms
12:54:09.401 INFO - Issues mode
12:54:09.401 INFO - Scanning only changed files
12:54:09.405 INFO - ------------- Scan MyProject
12:54:10.217 INFO - Language is forced to php
12:54:10.238 INFO - Load server rules
12:54:11.104 INFO - Load server rules (done) | time=866ms
12:54:11.233 INFO - Base dir: /projectpath/workspace
12:54:11.233 INFO - Working dir: /projectpath/.sonar
12:54:11.235 INFO - Source paths: app
12:54:11.235 INFO - Source encoding: UTF-8, default locale: en_US
12:54:11.236 INFO - Index files
12:54:11.265 INFO - Excluded sources:
12:54:11.266 INFO - app/Vendor/**
12:54:11.266 INFO - app/Plugin/**/Test/**
12:54:11.266 INFO - app/Test/**
12:54:11.266 INFO - app/Test/**
12:54:11.266 INFO - Included tests:
12:54:11.266 INFO - app/Test/**
12:54:16.551 INFO - 983 files indexed
12:54:16.552 INFO - 12296 files ignored because of inclusion/exclusion patterns
12:54:16.661 INFO - Quality profile for php: Sonar way
12:54:17.180 INFO - JaCoCoSensor: JaCoCo report not found : /projectpath/target/jacoco.exec
12:54:17.183 INFO - JaCoCoItSensor: JaCoCo IT report not found: /projectpath/target/jacoco-it.exec
12:54:17.220 INFO - Sensor NoSonar and Commented out LOC Sensor
12:54:17.926 INFO - Sensor NoSonar and Commented out LOC Sensor (done) | time=706ms
12:54:17.926 INFO - Sensor Lines Sensor
12:54:18.161 INFO - Sensor Lines Sensor (done) | time=235ms
12:54:18.162 INFO - Sensor PHPSensor
12:54:18.894 INFO - 509 source files to be analyzed
12:54:28.909 INFO - 265/509 files analyzed, current file: /projectpath/MyFile.php
12:54:38.479 INFO - Sensor PHPSensor (done) | time=20317ms
12:54:38.479 INFO - Sensor PHPUnit Sensor
12:54:38.479 INFO - 509/509 source files have been analyzed
12:54:38.480 INFO - PHPUnit xml test report not found: app/junit-output.xml
12:54:38.480 INFO - PHPUnit xml unit test coverage report not found: app/clover-coverage.xml
12:54:38.480 INFO - No PHPUnit integration test coverage report provided (see 'sonar.php.coverage.itReportPath' property)
12:54:38.480 INFO - No PHPUnit overall coverage report provided (see 'sonar.php.coverage.overallReportPath' property)
12:54:38.480 INFO - Sensor PHPUnit Sensor (done) | time=1ms
12:54:38.480 INFO - Load server issues
12:54:40.752 INFO - Load server issues (done) | time=2272ms
12:54:40.753 INFO - Performing issue tracking
12:54:43.215 INFO - 1210/1210 components tracked
12:54:43.216 INFO - ANALYSIS SUCCESSFUL
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
Total time: 45.188s
Final Memory: 7M/215M
INFO: ------------------------------------------------------------------------
Does anyone have any idea why this upgrade has stopped the SonarQube scanner from commenting/analyzing our pull request?
Duh, we forgot to install the github plugin on our new SonarQube instance...
The command output should include:
Starting analysis of pull request:
https://github.com/Organization/OurRepository/pull/2940
If it doesn't, you're most likely missing the github plugin.

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*

Access denied for Sonar database

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?

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

Accessing a temp table from DBUnit

I have a stored procedure in Sybase that returns some data in a temp table (let's call it #results). If I create this table from my own code and call the stored procedure and check the #results everything is fine (I use Python for this purpose). I can generate the expected result set for my test.
However when I try to create a DBUnit test case so that the code
creates the temp table via the Spring JdbcTemplate
calls this procedure and checks the returned data
I get a NoSuchTableException from DbUnit when checking the result set.
15:55:52.980 [main] DEBUG c.m.e.e.dbtest.helper.SQLTestHelper - *** expected table: #results
15:55:52.980 [main] DEBUG org.dbunit.dataset.FilteredDataSet - getTable(tableName=#results) - start
15:55:52.980 [main] DEBUG o.d.d.filter.SequenceTableFilter - accept(tableName=#results) - start
15:55:52.980 [main] DEBUG o.dbunit.dataset.OrderedTableNameMap - getTableName(tableName=#results) - start
15:55:52.980 [main] DEBUG o.dbunit.dataset.OrderedTableNameMap - getTableName(tableName=#results) - end - result=#RESULTS
15:55:52.980 [main] DEBUG org.dbunit.database.DatabaseDataSet - getTable(tableName=#results) - start
15:55:52.980 [main] DEBUG org.dbunit.database.DatabaseDataSet - initialize() - start
15:55:52.980 [main] DEBUG org.dbunit.database.DatabaseDataSet - Initializing the data set from the database...
15:55:52.980 [main] DEBUG o.d.d.DatabaseDataSourceConnection - getConnection() - start
15:55:52.980 [main] DEBUG m.b.t.TransactionResourceManager - Fetched TransactionResourceResolver [null]
15:55:52.980 [main] DEBUG msjava.pool.BasicObjectPool - Attempting to retrieve object from pool 'ConnectionPoolOf-dbunitDS'
15:55:52.980 [main] DEBUG msjava.pool.BasicObjectPool - Retrieved object 'TransactionInfoCachingConnection on DBCallSavingConnection on com.sybase.jdbc3.jdbc.SybConnection#170984c' from pool 'ConnectionPoolOf-dbunitDS'
15:55:53.402 [main] DEBUG org.dbunit.database.DatabaseDataSet -
database product name=Adaptive Server Enterprise
database major version=12
database minor version=5
jdbc driver name=jConnect (TM) for JDBC (TM)
jdbc driver version=jConnect (TM) for JDBC(TM)/6.05(Build 26564)/P/EBF16903/JDK14/Sun May 31 1:05:35 2009
jdbc driver major version=6
jdbc driver minor version=0
15:55:53.402 [main] DEBUG org.dbunit.database.DatabaseDataSet - metadata resultset=com.sybase.jdbc3.jdbc.SybResultSet#1b595f3
15:55:53.402 [main] DEBUG org.dbunit.database.DatabaseDataSet - getTableMetaData(tableName=#results) - start
15:55:53.402 [main] DEBUG org.dbunit.database.DatabaseDataSet - initialize() - start
15:55:53.402 [main] DEBUG o.dbunit.dataset.OrderedTableNameMap - getTableName(tableName=#results) - start
15:55:53.402 [main] DEBUG o.dbunit.dataset.OrderedTableNameMap - getTableName(tableName=#results) - end - result=#RESULTS
15:55:53.402 [main] ERROR org.dbunit.database.DatabaseDataSet - Table '#results' not found in tableMap=org.dbunit.dataset.OrderedTableNameMap[_tableNames=[], _tableMap={}, _caseSensitiveTableNames=false]
Checking the database in parallel with the test code execution (at a breakpoint) I can see that the temp table is indeed created in tempdb and filled with data.
Has anyone done such a thing successfully (eg. used a Sybase temp table from DbUnit)? If yes, how?
If you create temporary tables by using “#” as the first character of the table name:
Temporary tables:
Exist only for the duration of the user session or for the scope of the procedure that creates them
Cannot be shared between user connections
Are automatically dropped at the end of the session or procedure (or can be dropped manually)
You can create regular user tables in tempdb by specifying the database name in the command that creates the table:
Regular user tables in tempdb:
Can persist across sessions
Can be used by bulk copy operations
Can be shared by granting permissions on them
Must be explicitly dropped by the owner (otherwise, they are removed when Adaptive Server is restarted)

Resources