SonarScanner fails after plugin installation

Setup

  • Sonarqube 9.0.1.46107
  • Sonarscanner 4.6.2.2472 (linux)
  • Plugin Ansible-lint 2.5.0
  • Plugin Checkstyle 8.40
  • Plugin YAML Analyzer 1.6.0

Issue
Today I installed the two plugins for YAML and ansible respectively. Since restarting sonarqube all analyses fail with a NullPointerException on sonarqube/DefaultActiveRulesLoader.java at 233a760898a0f33891381e4a0e80553c91c17b45 · SonarSource/sonarqube · GitHub

It seems the active rulesets can no longer be loaded, even for projects that don’t rely on any yaml quality profiles.

The stacktrace is as follows:

Caused by: java.lang.NullPointerException
        at org.sonar.scanner.rule.DefaultActiveRulesLoader.readPage(DefaultActiveRulesLoader.java:103)
        at org.sonar.scanner.rule.DefaultActiveRulesLoader.load(DefaultActiveRulesLoader.java:63)
        at org.sonar.scanner.rule.ActiveRulesProvider.load(ActiveRulesProvider.java:100)
        at org.sonar.scanner.rule.ActiveRulesProvider.load(ActiveRulesProvider.java:63)
        at org.sonar.scanner.rule.ActiveRulesProvider.provide(ActiveRulesProvider.java:50)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

An uninstallation of the new plugins (removing the jar files and restarting sonarqube) did not resolve the issue.

Any help in how to fix the issue would be greatly appreciated.

I have collected the output from running sonar-scanner -X:

14:16:02.470 INFO: Load active rules
14:16:02.631 DEBUG: GET 200 https://<OUR_HOST>/sonarqube/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AXuClY_1Lkwz77xgNz5g&ps=500&p=1 | time=160ms
14:16:02.815 DEBUG: GET 200 https://<OUR_HOST>/sonarqube/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AXuClZERLkwz77xgN0Ad&ps=500&p=1 | time=35ms
14:16:02.907 DEBUG: GET 200 https://<OUR_HOST>/sonarqube/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AXuClZIcLkwz77xgN0Ha&ps=500&p=1 | time=87ms
14:16:02.964 DEBUG: GET 200 https://<OUR_HOST>/sonarqube/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AXuClZK_Lkwz77xgN0Lu&ps=500&p=1 | time=38ms
14:16:02.987 DEBUG: GET 200 https://<OUR_HOST>/sonarqube/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AXuClZMJLkwz77xgN0MO&ps=500&p=1 | time=18ms
14:16:03.013 DEBUG: GET 200 https://<OUR_HOST>/sonarqube/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AXuClZOhLkwz77xgN0PO&ps=500&p=1 | time=25ms
14:16:03.061 DEBUG: GET 200 https://<OUR_HOST>/sonarqube/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AXuClZMYLkwz77xgN0Nq&ps=500&p=1 | time=45ms
14:16:03.154 DEBUG: GET 200 https://<OUR_HOST>/sonarqube/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AXuClZQmLkwz77xgN0VS&ps=500&p=1 | time=89ms
14:16:03.251 DEBUG: GET 200 https://<OUR_HOST>/sonarqube/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AXuClZT9Lkwz77xgN0c4&ps=500&p=1 | time=83ms
14:16:03.328 DEBUG: GET 200 https://<OUR_HOST>/sonarqube/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AXuClZWoLkwz77xgN0hG&ps=500&p=1 | time=69ms
14:16:03.421 DEBUG: GET 200 https://<OUR_HOST>/sonarqube/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AXuClZaOLkwz77xgN0oA&ps=500&p=1 | time=90ms
14:16:03.468 DEBUG: GET 200 https://<OUR_HOST>/sonarqube/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AXuClZYtLkwz77xgN0jF&ps=500&p=1 | time=40ms
14:16:03.581 DEBUG: GET 200 https://<OUR_HOST>/sonarqube/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AXuClZeZLkwz77xgN0yn&ps=500&p=1 | time=110ms
14:16:03.865 DEBUG: GET 200 https://<OUR_HOST>/sonarqube/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AXuGscP4kAU74jFh6sfu&ps=500&p=1 | time=268ms
14:16:03.886 INFO: ------------------------------------------------------------------------
14:16:03.886 INFO: EXECUTION FAILURE
14:16:03.886 INFO: ------------------------------------------------------------------------
14:16:03.886 INFO: Total time: 3.892s
14:16:03.921 INFO: Final Memory: 6M/30M
14:16:03.921 INFO: --------------------------------------------------

I have then gone into the database and started looking around for the mentioned profiles, since the error seems to be indicating that no rules are active.

I found all the mentioned rule IDs in org_qprofiles, I then joined it to rules_profiles via org_qprofiles.rules_profile_uuid.
It shows 13 ‘built-in’ profiles and our custom Java profile. I took that profile ID and ran

select count(*) from active_rules ar where profile_uuid = 'AXuGscP4kAU74jFh6sfv'
> 503

The uuid is the id of our custom java profile. The number 503 matches what I can see on the sonarqube admin interface

Hopefully this helps narrowing down the issue

The problem is solved. This SO-Post pointed us to a solution.
What fixed the issue were the following steps

  1. Remove the YAML and Ansible Plugin from Sonarqube (move jars away)
  2. Stop sonarqube
  3. Remove elasticsearch data (i.e. /var/elasticsearch/data/es7)
  4. Start sonarqube

This restores the system to the point where it was before any plugin installation

Clean installation of the plugins (what worked for me, YMMV)

  1. Stop sonarqube
  2. Copy sonar-yaml-plugin.jar to your plugins folder
  3. Start sonarqube
  4. Open the auto-generated quality profile for YAML and select [Gear]->Set as default
  5. Stop sonarqube
  6. Copy sonar-ansible-plugin.jar to your plugins folder
  7. Start sonarqube

You’re all set :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.