Sonarqube 无法加载组件

Posted

技术标签:

【中文标题】Sonarqube 无法加载组件【英文标题】:Sonarqube unable to load component 【发布时间】:2018-09-27 13:00:14 【问题描述】:

在(自托管)vsts 代理上运行声纳扫描仪时出现错误。代理(visual studio 团队服务)在 kubernetes 集群 (linux) 上运行。

在 VSTS 中,我添加了 Sonarqube 准备和运行分析(通过 VSTS 市场检索)。在运行分析中,我收到以下错误:

2018-04-17T13:41:17.7246126Z 13:41:17.718 ERROR: Error during SonarQube Scanner execution
2018-04-17T13:41:17.7257629Z 13:41:17.718 ERROR: Unable to load component class org.sonar.scanner.report.ActiveRulesPublisher
2018-04-17T13:41:17.7289820Z 13:41:17.719 ERROR: Caused by: Unable to load component interface org.sonar.api.batch.rule.ActiveRules

声纳扫描仪的完整详细日志记录:

    2018-04-17T13:40:55.4491103Z Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
    2018-04-17T13:40:55.9843800Z INFO: Scanner configuration file: /vsts/agent/_work/_tasks/SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055/4.1.1/sonar-scanner/conf/sonar-scanner.properties
    2018-04-17T13:40:55.9872383Z INFO: Project root configuration file: NONE
    2018-04-17T13:40:56.0773880Z 13:40:56.071 INFO: SonarQube Scanner 3.1.0.1141
    2018-04-17T13:40:56.0788506Z 13:40:56.076 INFO: Java 1.8.0_162 Oracle Corporation (64-bit)
    2018-04-17T13:40:56.0805405Z 13:40:56.076 INFO: Linux 4.9.0-5-amd64 amd64
    2018-04-17T13:40:56.4592573Z 13:40:56.458 DEBUG: keyStore is : 
    2018-04-17T13:40:56.4608365Z 13:40:56.459 DEBUG: keyStore type is : jks
    2018-04-17T13:40:56.4620170Z 13:40:56.460 DEBUG: keyStore provider is : 
    2018-04-17T13:40:56.4631954Z 13:40:56.460 DEBUG: init keystore
    2018-04-17T13:40:56.4643759Z 13:40:56.461 DEBUG: init keymanager of type SunX509
    2018-04-17T13:40:56.5660597Z 13:40:56.564 DEBUG: Create: /root/.sonar/cache
    2018-04-17T13:40:56.5696355Z 13:40:56.568 INFO: User cache: /root/.sonar/cache
    2018-04-17T13:40:56.5709625Z 13:40:56.569 DEBUG: Create: /root/.sonar/cache/_tmp
    2018-04-17T13:40:56.5752714Z 13:40:56.574 DEBUG: Extract sonar-scanner-api-batch in temp...
    2018-04-17T13:40:56.5940510Z 13:40:56.592 DEBUG: Get bootstrap index...
    2018-04-17T13:40:56.5952154Z 13:40:56.593 DEBUG: Download: https://<url>/batch/index
    2018-04-17T13:40:56.7993378Z 13:40:56.798 DEBUG: Get bootstrap completed
    2018-04-17T13:40:56.8215666Z 13:40:56.818 DEBUG: Download https://<url>/batch/file?name=sonar-scanner-engine-shaded-6.5.jar to /root/.sonar/cache/_tmp/fileCache5321971657904640201.tmp
    2018-04-17T13:41:02.6399191Z 13:41:02.638 DEBUG: Create isolated classloader...
    2018-04-17T13:41:02.6506592Z 13:41:02.649 DEBUG: Start temp cleaning...
    2018-04-17T13:41:02.6644082Z 13:41:02.663 DEBUG: Temp cleaning done
    2018-04-17T13:41:02.6656506Z 13:41:02.663 DEBUG: Execution getVersion
    2018-04-17T13:41:02.6669835Z 13:41:02.665 INFO: SonarQube server 6.5.0
    2018-04-17T13:41:02.6684967Z 13:41:02.665 INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
    2018-04-17T13:41:02.6701596Z 13:41:02.666 DEBUG: Work directory: /vsts/agent/_work/1/s/.scannerwork
    2018-04-17T13:41:02.6713389Z 13:41:02.667 DEBUG: Execution execute
    2018-04-17T13:41:02.9257781Z 13:41:02.924 DEBUG: Publish global mode
    2018-04-17T13:41:03.0332419Z 13:41:03.032 INFO: Load global settings
    2018-04-17T13:41:03.1301467Z 13:41:03.128 DEBUG: GET 200 https://<url>/api/settings/values.protobuf | time=89ms
    2018-04-17T13:41:03.1423184Z 13:41:03.140 INFO: Load global settings (done) | time=109ms
    2018-04-17T13:41:03.1546880Z 13:41:03.153 INFO: User cache: /root/.sonar/cache
    2018-04-17T13:41:03.3769269Z 13:41:03.375 INFO: Load plugins index
    2018-04-17T13:41:03.3867504Z 13:41:03.385 DEBUG: GET 200 https://<url>/deploy/plugins/index.txt | time=9ms
    2018-04-17T13:41:03.3882935Z 13:41:03.387 INFO: Load plugins index (done) | time=12ms
    2018-04-17T13:41:03.3894980Z 13:41:03.388 DEBUG: Load plugins
    2018-04-17T13:41:03.3919841Z 13:41:03.390 DEBUG: Download plugin sonar-csharp-plugin-5.10.1.1411.jar to /root/.sonar/cache/_tmp/fileCache5198949102678735871.tmp
    2018-04-17T13:41:03.4017607Z 13:41:03.399 DEBUG: GET 200 https://<url>/deploy/plugins/csharp/sonar-csharp-plugin-5.10.1.1411.jar | time=9ms
    2018-04-17T13:41:06.7030760Z 13:41:06.699 DEBUG: Download plugin sonar-python-plugin-1.8.0.1496.jar to /root/.sonar/cache/_tmp/fileCache5837697557641973805.tmp
    2018-04-17T13:41:06.7140570Z 13:41:06.712 DEBUG: GET 200 https://<url>/deploy/plugins/python/sonar-python-plugin-1.8.0.1496.jar | time=11ms
    2018-04-17T13:41:07.7937342Z 13:41:07.792 DEBUG: Download plugin sonar-java-plugin-4.12.0.11033.jar to /root/.sonar/cache/_tmp/fileCache3113521041013245867.tmp
    2018-04-17T13:41:07.8036767Z 13:41:07.802 DEBUG: GET 200 https://<url>/deploy/plugins/java/sonar-java-plugin-4.12.0.11033.jar | time=10ms
    2018-04-17T13:41:09.1704132Z 13:41:09.169 DEBUG: Download plugin sonar-scm-git-plugin-1.2.jar to /root/.sonar/cache/_tmp/fileCache3652847485025121764.tmp
    2018-04-17T13:41:09.1814559Z 13:41:09.179 DEBUG: GET 200 https://<url>/deploy/plugins/scmgit/sonar-scm-git-plugin-1.2.jar | time=10ms
    2018-04-17T13:41:10.1258417Z 13:41:10.124 DEBUG: Download plugin sonar-flex-plugin-2.3.jar to /root/.sonar/cache/_tmp/fileCache1763014158619511232.tmp
    2018-04-17T13:41:10.1434478Z 13:41:10.141 DEBUG: GET 200 https://<url>/deploy/plugins/flex/sonar-flex-plugin-2.3.jar | time=17ms
    2018-04-17T13:41:10.5811390Z 13:41:10.579 DEBUG: Download plugin sonar-xml-plugin-1.4.3.1027.jar to /root/.sonar/cache/_tmp/fileCache4278096937563691973.tmp
    2018-04-17T13:41:10.5931521Z 13:41:10.591 DEBUG: GET 200 https://<url>/deploy/plugins/xml/sonar-xml-plugin-1.4.3.1027.jar | time=12ms
    2018-04-17T13:41:13.0089908Z 13:41:13.006 DEBUG: Download plugin sonar-php-plugin-2.10.0.2087.jar to /root/.sonar/cache/_tmp/fileCache8869518949034818200.tmp
    2018-04-17T13:41:13.0190680Z 13:41:13.017 DEBUG: GET 200 https://<url>/deploy/plugins/php/sonar-php-plugin-2.10.0.2087.jar | time=11ms
    2018-04-17T13:41:13.9587794Z 13:41:13.956 DEBUG: Download plugin sonar-scm-svn-plugin-1.5.0.715.jar to /root/.sonar/cache/_tmp/fileCache8353866177366095107.tmp
    2018-04-17T13:41:13.9686573Z 13:41:13.966 DEBUG: GET 200 https://<url>/deploy/plugins/scmsvn/sonar-scm-svn-plugin-1.5.0.715.jar | time=10ms
    2018-04-17T13:41:15.7441037Z 13:41:15.740 DEBUG: Download plugin sonar-javascript-plugin-3.1.1.5128.jar to /root/.sonar/cache/_tmp/fileCache1134031791761299423.tmp
    2018-04-17T13:41:15.7552087Z 13:41:15.753 DEBUG: GET 200 https://<url>/deploy/plugins/javascript/sonar-javascript-plugin-3.1.1.5128.jar | time=10ms
    2018-04-17T13:41:16.6007888Z 13:41:16.598 DEBUG: Load plugins (done) | time=13210ms
    2018-04-17T13:41:16.6656267Z 13:41:16.664 DEBUG: API compatibility mode is enabled on plugin Git [scmgit] (built with API lower than 5.2)
    2018-04-17T13:41:16.8080245Z 13:41:16.806 DEBUG: API compatibility mode is enabled on plugin SVN [scmsvn] (built with API lower than 5.2)
    2018-04-17T13:41:16.8782356Z 13:41:16.877 DEBUG: Plugins:
    2018-04-17T13:41:16.8803313Z 13:41:16.877 DEBUG:   * C# 5.10.1.1411 (csharp)
    2018-04-17T13:41:16.8814834Z 13:41:16.877 DEBUG:   * SonarPython 1.8.0.1496 (python)
    2018-04-17T13:41:16.8826606Z 13:41:16.878 DEBUG:   * SonarJava 4.12.0.11033 (java)
    2018-04-17T13:41:16.8838164Z 13:41:16.878 DEBUG:   * Git 1.2 (scmgit)
    2018-04-17T13:41:16.8849469Z 13:41:16.878 DEBUG:   * Flex 2.3 (flex)
    2018-04-17T13:41:16.8861132Z 13:41:16.878 DEBUG:   * SonarXML 1.4.3.1027 (xml)
    2018-04-17T13:41:16.8872441Z 13:41:16.878 DEBUG:   * SonarPHP 2.10.0.2087 (php)
    2018-04-17T13:41:16.8884157Z 13:41:16.878 DEBUG:   * SVN 1.5.0.715 (scmsvn)
    2018-04-17T13:41:16.8895519Z 13:41:16.879 DEBUG:   * SonarJS 3.1.1.5128 (javascript)
    2018-04-17T13:41:17.2954878Z 13:41:17.294 INFO: Process project properties
    2018-04-17T13:41:17.3024512Z 13:41:17.301 DEBUG: Process project properties (done) | time=7ms
    2018-04-17T13:41:17.3187780Z 13:41:17.317 INFO: Load project repositories
    2018-04-17T13:41:17.3400387Z 13:41:17.339 DEBUG: GET 200 https://<url>/batch/project.protobuf?key=<key> | time=20ms
    2018-04-17T13:41:17.3772015Z 13:41:17.376 INFO: Load project repositories (done) | time=59ms
    2018-04-17T13:41:17.4391020Z 13:41:17.438 DEBUG: Available languages:
    2018-04-17T13:41:17.4407025Z 13:41:17.438 DEBUG:   * C# => "cs"
    2018-04-17T13:41:17.4419498Z 13:41:17.439 DEBUG:   * Python => "py"
    2018-04-17T13:41:17.4431469Z 13:41:17.440 DEBUG:   * Java => "java"
    2018-04-17T13:41:17.4447051Z 13:41:17.440 DEBUG:   * Flex => "flex"
    2018-04-17T13:41:17.4459538Z 13:41:17.440 DEBUG:   * XML => "xml"
    2018-04-17T13:41:17.4471153Z 13:41:17.440 DEBUG:   * PHP => "php"
    2018-04-17T13:41:17.4483109Z 13:41:17.440 DEBUG:   * JavaScript => "js"
    2018-04-17T13:41:17.4494550Z 13:41:17.445 INFO: Load quality profiles
    2018-04-17T13:41:17.4667036Z 13:41:17.465 DEBUG: GET 200 https://<url>/api/qualityprofiles/search.protobuf?projectKey=<key> | time=20ms
    2018-04-17T13:41:17.4718216Z 13:41:17.471 INFO: Load quality profiles (done) | time=26ms
    2018-04-17T13:41:17.4787808Z 13:41:17.478 INFO: Load active rules
    2018-04-17T13:41:17.5539598Z 13:41:17.552 DEBUG: GET 200 https://<url>/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWLTddaUW_zM7o53qFW6&p=1&ps=500 | time=73ms
    2018-04-17T13:41:17.6794770Z 13:41:17.678 INFO: ------------------------------------------------------------------------
    2018-04-17T13:41:17.6808969Z 13:41:17.678 INFO: EXECUTION FAILURE
    2018-04-17T13:41:17.6823237Z 13:41:17.678 INFO: ------------------------------------------------------------------------
    2018-04-17T13:41:17.6838138Z 13:41:17.678 INFO: Total time: 21.735s
    2018-04-17T13:41:17.7207625Z 13:41:17.718 INFO: Final Memory: 8M/109M
    2018-04-17T13:41:17.7229316Z 13:41:17.718 INFO: ------------------------------------------------------------------------
    2018-04-17T13:41:17.7246126Z 13:41:17.718 ERROR: Error during SonarQube Scanner execution
    2018-04-17T13:41:17.7257629Z 13:41:17.718 ERROR: Unable to load component class org.sonar.scanner.report.ActiveRulesPublisher
    2018-04-17T13:41:17.7289820Z 13:41:17.719 ERROR: Caused by: Unable to load component interface org.sonar.api.batch.rule.ActiveRules
    2018-04-17T13:41:17.7301826Z 13:41:17.728 ERROR: 
    2018-04-17T13:41:17.7318487Z 13:41:17.728 ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
    2018-04-17T13:41:17.7530568Z ##[error]/vsts/agent/_work/_tasks/SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055/4.1.1/sonar-scanner/bin/sonar-scanner failed with return code: 1

【问题讨论】:

如果手动调用相关的sonarqube命令分析项目,结果如何?另一方面,尝试停止 SonarQube 服务器,清除 SONAR_QUE/data/es 文件夹,重新启动 SonarQube 服务器 【参考方案1】:

org.sonar.api.batch.rule.ActiveRules类是在sonar-plugin-api中定义的,所以我认为这个bug是由插件引起的。

我看到你使用C# 5.10.1.1411。我发现了这个问题:ActiveRulesPublisher issue for C# 5.10.1。记者使用与您完全相同的版本(5.10.1.1411)。应该可以解决您的问题的步骤:

停止 SonarQube 服务器 清除SONAR_QUBE/data/es 文件夹 重启 SonarQube 服务器 重新启动项目分析

【讨论】:

我遇到了Unable to load component class org.sonar.scanner.report.ActiveRulesPublisher,您的解决方案运行良好。在我们的例子中,SonarQube 7.9.1,文件夹被命名为data/es6

以上是关于Sonarqube 无法加载组件的主要内容,如果未能解决你的问题,请参考以下文章

Sonarqube 5.6.6 中未加载某些页面

SonarQube - 无法加载Wrapper的本机库'wrapper.dll'

SonarQube 8.9 无法启动,登录后加载页面被阻止

Angular 4 加载器无法按预期工作

Vue路由器无法加载组件

angular 2组件无法从外部css皮肤加载相对背景图像url