Adding a profile for a custom language breaks other projects (with a NullPointerException within Sonar)

112 views
Skip to first unread message

petr.h...@iongroup.com

unread,
Jan 9, 2018, 6:05:12 AM1/9/18
to SonarQube
Hello.
I created a custom Sonar plugin that adds a new language, new rules for that language a sensor for that language.
The project that I created afterwards that uses that plugin works fine as a multilanguage project, with both the new language and Java.
However, other projects, whether created before or after that, fail.

When I attempt to run "mvn sonar:sonar" on them, the following error results:

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar (default-cli) on project SampleProjectSonar2: Unable to load component class org.sonar.scanner.report.MetadataPublisher: Unable to load component class org.sonar.scanner.rule.ModuleQProfiles: E
rror 500 on http://localhost:9000/api/qualityprofiles/search.protobuf?projectKey=java.sk.hudecekpetr%3ASampleProjectSonar2 : {"errors":[{"msg":"An error has occurred. Please contact your administrator"}]} -> [Help 1]

When I go in Sonar web server log, it shows:

018.01.09 11:45:48 ERROR web[AWDByNoDzJDcGU53AAFe][o.s.s.w.WebServiceEngine] Fail to process request http://localhost:9000/api/qualityprofiles/search.protobuf?projectKey=java.sk.hudecekpetr%3ASampleProjectSonar2
java.lang.NullPointerException: null
at org.sonar.server.qualityprofile.ws.SearchAction.lambda$byProject$5(SearchAction.java:246)
at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source)
at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.util.stream.ReferencePipeline.collect(Unknown Source)
at org.sonar.server.qualityprofile.ws.SearchAction.searchProfiles(SearchAction.java:219)
at org.sonar.server.qualityprofile.ws.SearchAction.load(SearchAction.java:157)
at org.sonar.server.qualityprofile.ws.SearchAction.doHandle(SearchAction.java:145)
at org.sonar.server.qualityprofile.ws.SearchAction.handle(SearchAction.java:131)
at org.sonar.server.ws.WebServiceEngine.execute(WebServiceEngine.java:103)
at org.sonar.server.ws.WebServiceFilter.doFilter(WebServiceFilter.java:86)
at org.sonar.server.platform.web.MasterServletFilter$GodFilterChain.doFilter(MasterServletFilter.java:126)
at org.sonar.server.platform.web.MasterServletFilter.doFilter(MasterServletFilter.java:95)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.sonar.server.user.UserSessionFilter.doFilter(UserSessionFilter.java:87)
at org.sonar.server.user.UserSessionFilter.doFilter(UserSessionFilter.java:71)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.sonar.server.platform.web.SecurityServletFilter.doHttpFilter(SecurityServletFilter.java:72)
at org.sonar.server.platform.web.SecurityServletFilter.doFilter(SecurityServletFilter.java:48)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.sonar.server.platform.web.RedirectFilter.doFilter(RedirectFilter.java:61)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.sonar.server.platform.web.requestid.RequestIdFilter.doFilter(RequestIdFilter.java:63)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.sonar.server.platform.web.RootFilter.doFilter(RootFilter.java:62)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at ch.qos.logback.access.tomcat.LogbackValve.invoke(LogbackValve.java:256)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)

No other logs show anything abnormal.

The new project doesn't show the quality profile for the new language in its Quality Profiles, its quality profiles can no longer be changed (assigning new profiles to it seems to work, but they never show up on the project screen) and the page "Administration->Quality Profiles" for those projects is empty  and the line "Failed to load resource: the server responded with a status of 500 ()" shows up in console log.

Do you know what causes this and how can I avoid it?

Best regards,
Petr

Julien Lancelot

unread,
Jan 9, 2018, 8:00:34 AM1/9/18
to petr.h...@iongroup.com, SonarQube
Hi Petr,

Could you please tell use which version of SonarQube you're using ?
Could you also please return the result of <YOUR_SONARQUBE_SERVER>/api/qualityprofiles/search?language=<YOUR_NEW_LANGUAGE> ?

Thanks.
Regards,

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/fae398bc-077e-406b-a5d0-051abf011aae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Julien Lancelot | SonarSource

petr.h...@iongroup.com

unread,
Jan 9, 2018, 8:04:38 AM1/9/18
to SonarQube
Hello Julien

The SonarQube version is 6.7.0.33306.

The API call you described returns this:

{
   "profiles":[
      {
         "key":"AWBqxsxep-FMzANyV-n-",
         "name":"Robot Profile Test",
         "language":"robot",
         "languageName":"Robot Framework DSL",
         "isInherited":false,
         "isDefault":false,
         "activeRuleCount":13,
         "activeDeprecatedRuleCount":0,
         "projectCount":1,
         "rulesUpdatedAt":"2017-12-22T14:04:40+0000",
         "lastUsed":"2018-01-09T11:46:48+0100",
         "userUpdatedAt":"2017-12-22T15:04:40+0100",
         "organization":"default-organization",
         "isBuiltIn":false,
         "actions":{
            "edit":true,
            "setAsDefault":true,
            "copy":true
         }
      }
   ],
   "actions":{
      "create":true
   }
}

Thank you very much for looking at this.
Best regards,
Petr

petr.h...@iongroup.com

unread,
Jan 15, 2018, 3:06:05 AM1/15/18
to SonarQube
Bump.
If somebody has an idea of what I could try to bypass this error, I would be grateful. Is it possible that I forgot some initialization for the new language or something?

Best regards,
Petr

Julien Lancelot

unread,
Jan 22, 2018, 8:55:32 AM1/22/18
to petr.h...@iongroup.com, SonarQube
Hi Petr,

Sorry for the delai replying you, I think I've found the issue : there's no default quality profile for your new language. 
It's most probably because you've not defined a built-in one. You can use this API define one, and see how it's used in the plugin used in our integration test.

I hope it will fix your issue.
Regards



For more options, visit https://groups.google.com/d/optout.

Julien Lancelot

unread,
Jan 22, 2018, 9:31:37 AM1/22/18
to petr.h...@iongroup.com, SonarQube
And in fact a ticket already exists to properly fail in your case : https://jira.sonarsource.com/browse/SONAR-10283.

petr.h...@iongroup.com

unread,
Jan 23, 2018, 3:57:18 AM1/23/18
to SonarQube
Hello Julien.

Thank you! That looks like my issue, yep. In the meantime, I have bypassed it by adding the rules to the 'java' language but applying them to files with the '.robot' extension. Inelegant, but it worked. 

Best regards,
Petr

Julien Lancelot

unread,
Jan 23, 2018, 4:01:53 AM1/23/18
to petr.h...@iongroup.com, SonarQube
Hi Petr,

I'm happy that you've solved your issue. I would have recommend you to provide a built-in quality profile in your plugin in order to fix this issue, but it's up to you !

Regards,


For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages