9

We just upgraded to SQ 6.0 and now some projects get the following error when analyzing with maven:

[INFO] --- sonar-maven-plugin:3.1.1:sonar (default-cli) @ gitlab-hook-dispatcher ---
[INFO] User cache: C:\Users\frank.jakop\.sonar\cache
[INFO] Load global repositories
[INFO] Load global repositories (done) | time=94ms
[INFO] User cache: C:\Users\frank.jakop\.sonar\cache
[INFO] Load plugins index
[INFO] Load plugins index (done) | time=5ms
[INFO] SonarQube version: 6.0
[INFO] Default locale: "de_DE", source code encoding: "UTF-8"
[INFO] Process project properties
[INFO] Load project repositories
[INFO] Load project repositories (done) | time=162ms
[INFO] Execute project builders
[INFO] Execute project builders (done) | time=1ms
[INFO] Load quality profiles
[INFO] Load quality profiles (done) | time=73ms
[INFO] Load active rules
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.419 s
[INFO] Finished at: 2016-09-14T08:29:20+02:00
[INFO] Final Memory: 67M/495M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.1.1:sonar (default-cli) on project gitlab-hook-dispatcher: Unable to load component class org.sonar.scanner.report.ActiveRulesPublisher: Unable to load component interface org.sonar.api.batch.rule.ActiveRules: NullPointerException -> [Help 1]

Last part of trace is

Caused by: java.lang.NullPointerException
    at org.sonar.scanner.rule.DefaultActiveRulesLoader.readPage(DefaultActiveRulesLoader.java:99)
    at org.sonar.scanner.rule.DefaultActiveRulesLoader.load(DefaultActiveRulesLoader.java:59)
    at org.sonar.scanner.rule.ActiveRulesProvider.load(ActiveRulesProvider.java:102)
    at org.sonar.scanner.rule.ActiveRulesProvider.load(ActiveRulesProvider.java:63)
    at org.sonar.scanner.rule.ActiveRulesProvider.provide(ActiveRulesProvider.java:49)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.picocontainer.injectors.MethodInjector.invokeMethod(MethodInjector.java:129)
    at org.picocontainer.injectors.MethodInjector.access$000(MethodInjector.java:39)
    at org.picocontainer.injectors.MethodInjector$2.run(MethodInjector.java:113)
    at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
    at org.picocontainer.injectors.MethodInjector.decorateComponentInstance(MethodInjector.java:120)
    at org.picocontainer.injectors.CompositeInjector.decorateComponentInstance(CompositeInjector.java:58)
    at org.picocontainer.injectors.Reinjector.reinject(Reinjector.java:142)
    at org.picocontainer.injectors.ProviderAdapter.getComponentInstance(ProviderAdapter.java:96)
    at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
    at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
    at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:67)
    ... 72 more

This happens also when we use org.codehaus.mojo:sonar-maven-plugin:2.7.1:sonar and seems to be project specific, some projects work and some don't.

Can anyone provide a hint what's wrong here?

G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76
Frank
  • 741
  • 1
  • 10
  • 24

1 Answers1

10

Credit to @teryk-sonarsource-team, just making it an answer:

  1. Delete the directory data/es in your SonarQube installation.
  2. Restart SonarQube.

It will recompute all the ES indexes.

This resolved the problem for me in SonarQube 5.6.3.

davidfmatheson
  • 3,539
  • 19
  • 27
  • 2
    I had the same issue and deleting 'data/es' was part of the solution. However, I had to restart my Sonarqube instance in order to take effect. Many thanks – Sylvester Loreto Nov 22 '16 at 15:11
  • @SylvesterAbreu Made restart explicit in answer. – davidfmatheson Nov 28 '16 at 14:50
  • Note that rebuilding ElasticSearch index is (as always) just a _workaround_. Underlying issue has been identified, it is tracked @ [SONAR-8887](https://jira.sonarsource.com/browse/SONAR-8887) and will be fixed in future versions. – Nicolas B. Mar 08 '17 at 11:17
  • I have installed Sonarqube on a docker container on Ubuntu. Where can i find my ES directory. Any clues ? – Ajith M A Apr 12 '17 at 06:03
  • This solution worked for me when upgraded from Sonar 5.6LTS to 6.7LTS, thanks ! – Bruno Lavit Jun 06 '18 at 08:44