Sonar xml架构验证规则导致ClassNotFoundException

时间:2015-07-17 10:47:10

标签: xml sonarqube sonar-runner sonarqube-4.5 sonarqube5.1

我们正在使用XML语言Sonar插件并成功添加了一些自定义XPath规则,但是当我们激活模式检查规则时,我们得到一个ClassNotFoundException:

org.sonar.api.utils.SonarException: java.lang.ClassNotFoundException: org.apache.xerces.dom.DOMImplementationSourceImpl

最初我们使用Sonar版本5.1.1,使用Oracle Java版本“1.8.0_45”在Ubuntu 14.04上安装了1.3版本的XML语言插件 - 我们实际上尝试了各种1.7和1.8 Javas。我们尝试使用Sonar runner v2.4首先运行分析,然后使用Sonar ant任务v2.3,两者都给出了相同的错误。

我们发现JIRA已经提出了这个问题:SONARXML-3但它已被关闭为“无法解决”,因为无法在SonarQube 4.5.4上复制。

我们使用XML语言插件的1.3版将Sonar 4.5.4全新安装到Windows机器上并使用了一个非常简单的测试用例。

安装完成后,我们执行了以下操作:

  • 根据“XML架构应该有效”规则
  • 创建自定义规则
  • 将架构保留为默认的“autodetect”并将filePattern设置为“** / * .html”
  • 在XML插件的文件后缀设置中添加了“html”
  • 在“Sonar Way”个人资料中激活自定义规则

当我们在单个html文件上运行声纳转轮时,我们仍然会遇到同样的错误。

我查看了XML插件jar,它在其META-INF / lib中包含xercesImpl-2.8.1.jar,其中包含它抱怨它无法找到的类。

我不确定下一步该尝试什么。我们在配置Sonar服务器或Sonar跑步者时错过了一个步骤吗?

已编辑添加简单的项目信息:

用于分析的单个文件,Basic.html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Title of document</title>
  </head>
  <body>
    some content 
  </body>
</html>

sonar-project.properties:

sonar.projectKey=simple:schema-test
sonar.projectName=Schema Check Test
sonar.projectVersion=1.0
sonar.sources=.

声纳 - 跑步者的输出:

SonarQube Runner 2.4
Java 1.8.0_45 Oracle Corporation (64-bit)
Linux 3.13.0-57-generic amd64
INFO: Runner configuration file: /home/mike/SonarDev/sonar-runner-2.4/conf/sonar-runner.properties
INFO: Project configuration file: /home/mike/SonarDev/SimpleSchema/sonar-project.properties
INFO: Default locale: "en_GB", source code encoding: "UTF-8"
INFO: Work directory: /home/mike/SonarDev/SimpleSchema/./.sonar
INFO: SonarQube Server 4.5.4
13:08:39.283 INFO  - Load global referentials...
13:08:39.765 INFO  - Load global referentials done: 488 ms
13:08:39.805 INFO  - User cache: /home/mike/.sonar/cache
13:08:39.837 INFO  - Install plugins
13:08:39.864 INFO  - Download sonar-core-plugin-4.5.4.jar
13:08:39.933 INFO  - Download sonar-email-notifications-plugin-4.5.4.jar
13:08:39.979 INFO  - Download sonar-findbugs-plugin-2.4.jar
13:08:40.258 INFO  - Download sonar-java-plugin-2.4.jar
13:08:40.328 INFO  - Download sonar-xml-plugin-1.3.jar
13:08:40.512 INFO  - Download sonar-cpd-plugin-4.5.4.jar
13:08:40.528 INFO  - Download sonar-design-plugin-4.5.4.jar
13:08:40.553 INFO  - Download sonar-dbcleaner-plugin-4.5.4.jar
13:08:40.577 INFO  - Download sonar-l10n-en-plugin-4.5.4.jar
13:08:40.683 INFO  - Install JDBC driver
13:08:40.713 INFO  - Download mysql-connector-java-5.1.27.jar
13:08:40.761 INFO  - Create JDBC datasource for jdbc:mysql://localhost:3306/sonar4?useUnicode=true&amp;characterEncoding=utf8
13:08:44.377 INFO  - Initializing Hibernate
13:08:47.843 INFO  - Load project referentials...
13:08:48.430 INFO  - Load project referentials done: 587 ms
13:08:48.438 INFO  - Load project settings
13:08:49.256 INFO  - Loading technical debt model...
13:08:49.348 INFO  - Loading technical debt model done: 92 ms
13:08:49.372 INFO  - Apply project exclusions
13:08:49.988 INFO  - -------------  Scan Schema Check Test
13:08:50.018 INFO  - Load module settings
13:08:51.201 INFO  - Loading rules...
13:08:51.930 INFO  - Loading rules done: 725 ms
13:08:52.035 INFO  - Configure Maven plugins
13:08:52.447 INFO  - Compare to previous analysis (2015-07-22)
13:08:52.475 INFO  - Compare over 30 days (2015-06-22, analysis of 2015-07-22 12:56:55.0)
13:08:52.480 INFO  - No quality gate is configured.
13:08:53.015 INFO  - Base dir: /home/mike/SonarDev/SimpleSchema/.
13:08:53.022 INFO  - Working dir: /home/mike/SonarDev/SimpleSchema/./.sonar
13:08:53.024 INFO  - Source paths: .
13:08:53.024 INFO  - Source encoding: UTF-8, default locale: en_GB
13:08:53.024 INFO  - Index files
13:08:53.224 INFO  - 1 files indexed
13:08:53.370 INFO  - Quality profile for xml: Sonar way
13:08:53.422 INFO  - Sensor QProfileSensor...
13:08:53.464 INFO  - Sensor QProfileSensor done: 42 ms
13:08:53.466 INFO  - Sensor InitialOpenIssuesSensor...
13:08:53.504 INFO  - Sensor InitialOpenIssuesSensor done: 38 ms
13:08:53.510 INFO  - Sensor ProjectLinksSensor...
13:08:53.533 INFO  - Sensor ProjectLinksSensor done: 23 ms
13:08:53.539 INFO  - Sensor VersionEventsSensor...
13:08:53.592 INFO  - Sensor VersionEventsSensor done: 53 ms
13:08:53.593 INFO  - Sensor FileHashSensor...
13:08:53.608 INFO  - Sensor FileHashSensor done: 15 ms
13:08:53.608 INFO  - Sensor XmlSensor...
13:08:54.071 ERROR - Could not analyze the file /home/mike/SonarDev/SimpleSchema/Basic.html
org.sonar.api.utils.SonarException: java.lang.ClassNotFoundException: org.apache.xerces.dom.DOMImplementationSourceImpl
        at org.sonar.plugins.xml.schemas.SchemaResolver.createLSInput(SchemaResolver.java:122) ~[na:na]
        at org.sonar.plugins.xml.schemas.SchemaResolver.resolveResource(SchemaResolver.java:269) ~[na:na]
        at com.sun.org.apache.xerces.internal.util.DOMEntityResolverWrapper.resolveEntity(DOMEntityResolverWrapper.java:117) ~[na:1.8.0_45]
        at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.resolveEntity(XMLEntityManager.java:1079) ~[na:1.8.0_45]
        at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.resolveDocument(XMLSchemaLoader.java:660) ~[na:1.8.0_45]
        at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.resolveSchema(XSDHandler.java:2052) ~[na:1.8.0_45]
        at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.constructTrees(XSDHandler.java:1008) ~[na:1.8.0_45]
        at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:620) ~[na:1.8.0_45]
        at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:617) ~[na:1.8.0_45]
        at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:575) ~[na:1.8.0_45]
        at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:541) ~[na:1.8.0_45]
        at com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema(XMLSchemaFactory.java:255) ~[na:1.8.0_45]
        at org.sonar.plugins.xml.checks.XmlSchemaCheck.createSchema(XmlSchemaCheck.java:146) ~[na:na]
        at org.sonar.plugins.xml.checks.XmlSchemaCheck.validate(XmlSchemaCheck.java:232) ~[na:na]
        at org.sonar.plugins.xml.checks.XmlSchemaCheck.autodetectSchemaAndValidate(XmlSchemaCheck.java:164) ~[na:na]
        at org.sonar.plugins.xml.checks.XmlSchemaCheck.validate(XmlSchemaCheck.java:222) ~[na:na]
        at org.sonar.plugins.xml.checks.XmlSchemaCheck.validate(XmlSchemaCheck.java:260) ~[na:na]
        at org.sonar.plugins.xml.XmlSensor.analyse(XmlSensor.java:77) ~[na:na]
        at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:79) [sonar-batch-maven-compat-4.5.4.jar:na]
        at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:70) [sonar-batch-maven-compat-4.5.4.jar:na]
        at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:119) [sonar-batch-maven-compat-4.5.4.jar:na]
        at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:194) [sonar-batch-maven-compat-4.5.4.jar:na]
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93) [sonar-batch-maven-compat-4.5.4.jar:na]
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78) [sonar-batch-maven-compat-4.5.4.jar:na]
        at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:233) [sonar-batch-maven-compat-4.5.4.jar:na]
        at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:228) [sonar-batch-maven-compat-4.5.4.jar:na]
        at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:221) [sonar-batch-maven-compat-4.5.4.jar:na]
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93) [sonar-batch-maven-compat-4.5.4.jar:na]
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78) [sonar-batch-maven-compat-4.5.4.jar:na]
        at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:64) [sonar-batch-maven-compat-4.5.4.jar:na]
        at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:51) [sonar-batch-maven-compat-4.5.4.jar:na]
        at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:125) [sonar-batch-maven-compat-4.5.4.jar:na]
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93) [sonar-batch-maven-compat-4.5.4.jar:na]
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78) [sonar-batch-maven-compat-4.5.4.jar:na]
        at org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapContainer.java:173) [sonar-batch-maven-compat-4.5.4.jar:na]
        at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95) [sonar-batch-maven-compat-4.5.4.jar:na]
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67) [sonar-batch-maven-compat-4.5.4.jar:na]
        at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48) [sonar-runner-batch2088275009626652419.jar:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_45]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_45]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_45]
        at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_45]
        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87) [sonar-runner-dist-2.4.jar:na]
        at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75) [sonar-runner-dist-2.4.jar:na]
        at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_45]
        at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69) [sonar-runner-dist-2.4.jar:na]
        at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50) [sonar-runner-dist-2.4.jar:na]
        at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102) [sonar-runner-dist-2.4.jar:na]
        at org.sonar.runner.api.Runner.execute(Runner.java:100) [sonar-runner-dist-2.4.jar:na]
        at org.sonar.runner.Main.executeTask(Main.java:70) [sonar-runner-dist-2.4.jar:na]
        at org.sonar.runner.Main.execute(Main.java:59) [sonar-runner-dist-2.4.jar:na]
        at org.sonar.runner.Main.main(Main.java:53) [sonar-runner-dist-2.4.jar:na]
Caused by: java.lang.ClassNotFoundException: org.apache.xerces.dom.DOMImplementationSourceImpl
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_45]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_45]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_45]
        at org.w3c.dom.bootstrap.DOMImplementationRegistry.newInstance(DOMImplementationRegistry.java:182) ~[na:1.8.0_45]
        at org.sonar.plugins.xml.schemas.SchemaResolver.createLSInput(SchemaResolver.java:115) ~[na:na]
        ... 51 common frames omitted
13:08:54.077 INFO  - Sensor XmlSensor done: 469 ms
13:08:54.079 INFO  - Sensor LineCountSensor...
13:08:54.110 INFO  - Sensor LineCountSensor done: 31 ms
13:08:54.112 INFO  - Sensor CPD Sensor (wrapped)...
13:08:54.112 INFO  - DefaultCpdEngine is used for xml
13:08:54.114 INFO  - Cross-project analysis disabled
13:08:54.148 INFO  - Sensor CPD Sensor (wrapped) done: 36 ms
13:08:54.639 INFO  - Execute decorators...
13:08:55.155 INFO  - Store results in database
13:08:55.494 INFO  - ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/simple:schema-test
13:08:55.592 INFO  - Executing post-job class org.sonar.plugins.core.issue.notification.SendIssueNotificationsPostJob
13:08:55.593 INFO  - Executing post-job class org.sonar.plugins.core.batch.IndexProjectPostJob
13:08:55.698 INFO  - Executing post-job class org.sonar.plugins.dbcleaner.ProjectPurgePostJob
13:08:55.782 INFO  - -> Keep one snapshot per day between 2015-06-24 and 2015-07-21
13:08:55.793 INFO  - -> Keep one snapshot per week between 2014-07-23 and 2015-06-24
13:08:55.799 INFO  - -> Keep one snapshot per month between 2010-07-28 and 2014-07-23
13:08:55.809 INFO  - -> Delete data prior to: 2010-07-28
13:08:55.826 INFO  - -> Clean Schema Check Test [id=312]
13:08:55.860 INFO  - <- Clean snapshot 695
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
Total time: 18.958s
Final Memory: 12M/118M
INFO: ------------------------------------------------------------------------

0 个答案:

没有答案