2016-11-24 145 views
0

我已經爲了有各類分析......我的配置服務器SonarQube和我的Python項目(很正常...)SonarQube ClassNotFoundException的python的自定義規則

我想添加規則確保我已經在所有python腳本文件的開始處放置了許可證/版權文本。通過使用sslr-python-toolkit-1.5應用程序,我成功創建了規則XPath,規則也在SonarQube服務器上創建和激活。

但是,當我發動聲納的分析,我有一個堆棧跟蹤:

ERROR: Error during SonarQube Scanner execution 
org.sonar.api.utils.SonarException: Unable to initialize the XPath engine, perhaps because of an invalid query: //FILE_INPUT/STATEMENT[0][@tokenValue[not(contains(.,"''' Copyright .... '''"))]] 
     at org.sonar.squidbridge.checks.AbstractXPathCheck.init(AbstractXPathCheck.java:47) 
     at org.sonar.squidbridge.AstScanner.scanFiles(AstScanner.java:82) 
     at org.sonar.plugins.python.PythonSquidSensor.execute(PythonSquidSensor.java:106) 
     at org.sonar.batch.sensor.SensorWrapper.analyse(SensorWrapper.java:57) 
     at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58) 
     at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50) 
     at org.sonar.batch.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:83) 
     at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192) 
     at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) 
     at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) 
     at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:241) 
     at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:236) 
     at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:234) 
     at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:226) 
     at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) 
     at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) 
     at org.sonar.batch.task.ScanTask.execute(ScanTask.java:47) 
     at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86) 
     at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) 
     at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) 
     at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:106) 
     at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119) 
     at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:62) 
     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.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60) 
     at com.sun.proxy.$Proxy0.execute(Unknown Source) 
     at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:233) 
     at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151) 
     at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:110) 
     at org.sonarsource.scanner.cli.Main.execute(Main.java:74) 
     at org.sonarsource.scanner.cli.Main.main(Main.java:61) 
Caused by: java.lang.RuntimeException: org.jaxen.JaxenException: org.jaxen.saxpath.base.XPathReader 
     at com.google.common.base.Throwables.propagate(Throwables.java:156) 
     at com.sonar.sslr.xpath.api.AstNodeXPathQuery.<init>(AstNodeXPathQuery.java:39) 
     at com.sonar.sslr.xpath.api.AstNodeXPathQuery.create(AstNodeXPathQuery.java:103) 
     at org.sonar.squidbridge.checks.AbstractXPathCheck.init(AbstractXPathCheck.java:45) 
     ... 33 more 
Caused by: org.jaxen.JaxenException: org.jaxen.saxpath.base.XPathReader 
     at org.jaxen.BaseXPath.<init>(BaseXPath.java:125) 
     at org.jaxen.BaseXPath.<init>(BaseXPath.java:142) 
     at com.sonar.sslr.xpath.api.AstNodeXPathQuery.<init>(AstNodeXPathQuery.java:37) 
     ... 35 more 
Caused by: org.jaxen.saxpath.SAXPathException: org.jaxen.saxpath.base.XPathReader 
     at org.jaxen.saxpath.helpers.XPathReaderFactory.createReader(XPathReaderFactory.java:152) 
     at org.jaxen.saxpath.helpers.XPathReaderFactory.createReader(XPathReaderFactory.java:110) 
     at org.jaxen.BaseXPath.<init>(BaseXPath.java:113) 
     ... 37 more 
Caused by: java.lang.ClassNotFoundException: org.jaxen.saxpath.base.XPathReader 
     at org.sonar.classloader.ParentFirstStrategy.loadClass(ParentFirstStrategy.java:39) 
     at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:87) 
     at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:76) 
     at java.lang.Class.forName0(Native Method) 
     at java.lang.Class.forName(Class.java:348) 
     at org.jaxen.saxpath.helpers.XPathReaderFactory.createReader(XPathReaderFactory.java:137) 
     ... 39 more 
  1. 我試圖啓動聲納掃描儀自己的命令行

    在/ usr/bin/java -cp sslr-python-toolkit-1.5.jar:sonar-scanner-cli-2.8.jar -Dscanner.home =/opt/sonar-scanner -Dproject.home =/home/dev/workspaces/pepyt org。 sonarsource.scanner.cli.Main

但相同的結果....

  • 我在一個單獨的目錄,並沒有改變解壓都罐子...
  • 一些搜索後,我發現一些後約SONAR_SCANNER_OPTS環境變量的sonar-java-libraries ...如果使用環境變量(在聲納運行日誌中可以看到)沒有解決問題的事件...
  • 我把sslr-python-toolkit -1.5.jar庫在我的聲納主目錄的lib目錄中沒有任何成功
  • 我用完了想法...

    如何將sslr python庫添加到我的sonar-scanner類路徑中,以便使用我的自定義規則分析代碼?

    Cormandyr

    回答

    0

    這是SonarQube Python的插件一個bug。它將在下一個版本中修復。感謝您的反饋意見!

    相關問題