org.apache.ibatis.exceptions.PersistenceException - for Issues.locations being empty

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube 6.1
    SonarQube Scanner 2.8
    PostgreSQL 9.4.20
    Driver -PostgreSQL Native Driver Driver VersionPostgreSQL 9.4 JDBC4.2 (build 1206)
    SonarQube plugins:
    • SonarPython 1.8.0.1496 (python)
    • JSON 2.3 (JSON)
    • SVN 1.3 (scmsvn)
    • JavaScript 2.14 (javascript)
    • SonarPLSQL 3.0.1.1427 (plsql)
    • C# 5.3.1 (csharp)
    • Groovy 1.5 (groovy)
    • Java 4.0 (java)
    • LDAP 2.1.0.507 (ldap)
    • Web 2.5.0.476 (web)
    • Git 1.2 (scmgit)
    • SonarXML 1.4.3.1027 (xml)
  • what are you trying to achieve
    Run sonar scan from Jenkins Node which is installed with SonarQube Scanner 2.8. The scan runs successfully and the report is posted to Sonarqube. At sonarqube the report analysis (Backgroud task) fails with the below error.

org.apache.ibatis.exceptions.PersistenceException:

Error committing transaction. Cause: org.apache.ibatis.executor.BatchExecutorException: org.sonar.db.issue.IssueMapper.insert (batch index #1) failed. Cause: java.sql.BatchUpdateException: Batch entry 0 INSERT INTO issues (kee, rule_id, severity, manual_severity,

message, line, locations, gap, effort, status, tags,
resolution, checksum, assignee, author_login, issue_attributes, issue_creation_date, issue_update_date,
issue_close_date, created_at, updated_at, component_uuid, project_uuid, issue_type)
VALUES ('AWx2yGY9K7WxhoATfj8x', 611,
'MAJOR',
'0', 'Refactor this code to not nest more than 3 if/for/while/switch/try statements.', 547,
?,
NULL, 10, 'OPEN',
'brain-overload', NULL, '3acb83e5ced7c84575cf40a181e4d719',
NULL, 'bp@abc.com',
'',
1565360914000,1565360914000, NULL,
1565360946110, 1565360946110,
'AWxy1hn2K7WxhoATfcgY', 'AWxy1hHDIISw5q46GEMO', 1) was aborted.  Call getNextException to see the cause.

Cause: org.apache.ibatis.executor.BatchExecutorException: org.sonar.db.issue.IssueMapper.insert (batch index #1) failed. Cause: java.sql.BatchUpdateException: Batch entry 0 INSERT INTO issues (kee, rule_id, severity, manual_severity,

message, line, locations, gap, effort, status, tags,
resolution, checksum, assignee, author_login, issue_attributes, issue_creation_date, issue_update_date,
issue_close_date, created_at, updated_at, component_uuid, project_uuid, issue_type)
VALUES ('AWx2yGY9K7WxhoATfj8x', 611,
'MAJOR',
'0', 'Refactor this code to not nest more than 3 if/for/while/switch/try statements.', 547,
?,
NULL, 10, 'OPEN',
'brain-overload', NULL, '3acb83e5ced7c84575cf40a181e4d719',
NULL, 'bp@abc.com',
'',
1565360914000,1565360914000, NULL,
1565360946110, 1565360946110,
'AWxy1hn2K7WxhoATfcgY', 'AWxy1hHDIISw5q46GEMO', 1) was aborted.  Call getNextException to see the cause.
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:26)
at org.apache.ibatis.session.defaults.DefaultSqlSession.commit(DefaultSqlSession.java:177)
at org.apache.ibatis.session.defaults.DefaultSqlSession.commit(DefaultSqlSession.java:169)
at org.sonar.db.DbSession.commit(DbSession.java:41)
at org.sonar.db.BatchSession.commit(BatchSession.java:168)
at org.sonar.db.BatchSession.increment(BatchSession.java:205)
at org.sonar.db.BatchSession.insert(BatchSession.java:125)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:51)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
at com.sun.proxy.$Proxy47.insert(Unknown Source)
at org.sonar.server.computation.task.projectanalysis.step.PersistIssuesStep.execute(PersistIssuesStep.java:71)
at org.sonar.server.computation.task.step.ComputationStepExecutor.executeSteps(ComputationStepExecutor.java:64)
at org.sonar.server.computation.task.step.ComputationStepExecutor.execute(ComputationStepExecutor.java:52)
at org.sonar.server.computation.task.projectanalysis.taskprocessor.ReportTaskProcessor.process(ReportTaskProcessor.java:75)
at org.sonar.server.computation.taskprocessor.CeWorkerCallableImpl.executeTask(CeWorkerCallableImpl.java:84)
at org.sonar.server.computation.taskprocessor.CeWorkerCallableImpl.call(CeWorkerCallableImpl.java:57)
at org.sonar.server.computation.taskprocessor.CeWorkerCallableImpl.call(CeWorkerCallableImpl.java:35)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
  • what have you tried so far to achieve this

Upon analyzing why the insert statement fails, the ‘location’ is having ‘?’ instead of binary value which is expected and hence the insert stmt is failing.

Can anyone help on why this (‘locations’) is not getting populated.?

Version of scanner and SonarQube you use are quite old (10/2016), it will be difficult to troubleshoot such old version. I would advise to upgrade to the more recent version and try if issue persists.