简体   繁体   English

SonarQube 4.0和Xerces

[英]SonarQube 4.0 and Xerces

I'm working in the development of a custom plugin for sonar which generates a report and exports it to PDF. 我正在开发声纳的自定义插件,该插件可生成报告并将其导出为PDF。 For that purpose I use one of our libraries with xercesimpl 2.9.1 dependency. 为此,我使用了一个具有xercesimpl 2.9.1依赖关系的库。

This plugin works with SonarQube 3.7.4 but I'm getting a ClassNotFoundException with SonarQube 4.0 when I analyze a project with "mvn sonar:sonar" 该插件可用于SonarQube 3.7.4,但当我使用“ mvn sonar:sonar”分析项目时,SonarQube 4.0出现了ClassNotFoundException异常

Caused by: java.lang.NoClassDefFoundError: org/apache/xerces/dom/DocumentImpl
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:389)
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:235)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
at es.excentia.qalitax.report.service.OdtReport.getPdfOutputFile(OdtReport.java:103)
at es.excentia.sonar.odtreports.OdtReportPostJob.generateAndSaveReport(OdtReportPostJob.java:204)
at es.excentia.sonar.odtreports.OdtReportPostJob.executeOnIfLicenseOk(OdtReportPostJob.java:96)
at es.excentia.sonar.licenser.LicensedPostjob.executeOnIfEnabled(LicensedPostjob.java:29)
at es.excentia.sonar.plugins.common.DisableablePostjob.executeOn(DisableablePostjob.java:21)

It seems sonar-plugin-api requires also xercesimpl, but 2.8.1 version, so I have tried some things 似乎sonar-plugin-api也需要xercesimpl,但是版本2.8.1,所以我尝试了一些方法

  1. To exclude all xercesimpl dependencies, because since jdk 1.4 xercesimpl is also included -> Wrong. 排除所有xercesimpl依赖性,因为自从jdk 1.4起xercesimpl也被包含->错误。 Cast exception obtained. 获得强制转换异常。
  2. To exclude xercesimpl dependency in my package (v2.9.1) and leave just the sonar dependencies (2.8.1). 在我的程序包(v2.9.1)中排除xercesimpl依赖性,仅保留声纳依赖性(2.8.1)。 -> Got the same error. ->有同样的错误。 Class Not found. 未找到类。
  3. To exclude xercesimpl dependency in sonar-plugin-api and leave my package's dependency. 在sonar-plugin-api中排除xercesimpl依赖性,并保留我程序包的依赖性。 -> Now the plugin jar includes xercesimpl.jar but I got the same error. ->现在插件jar包含xercesimpl.jar,但是出现了相同的错误。 I tried to activate "useChildFirstClassLoader" to load xercesimpl 2.9.1 before sonar, but with no luck. 我试图激活“ useChildFirstClassLoader”以在声纳之前加载xercesimpl 2.9.1,但是没有运气。

I have read several posts about this, like "Xerces Hell" . 我已经阅读了一些有关此的文章,例如“ Xerces Hell” I also have read that maybe it's a jvm problem , but I have tried it with jdk 6 and 7 with same result. 我也读过也许是jvm问题 ,但是我已经用jdk 6和7尝试了相同的结果。

Any idea? 任何想法?

UPDATE 更新

I did it work copying xercesimpl.jar and xml-apis.jar to the sonar webserver directory: sonarqube-4.0\\web\\WEB-INF\\lib 我完成了将xercesimpl.jar和xml-apis.jar复制到声纳网络服务器目录的工作:sonarqube-4.0 \\ web \\ WEB-INF \\ lib

Is there any way to avoid this? 有什么办法可以避免这种情况?

I tried to modify my pom dependencies to include both libraries in my plugin jar, but when I run the analysis I get the same error. 我试图修改我的pom依赖项以在我的插件jar中包含两个库,但是当我运行分析时,我遇到了相同的错误。

OK. 好。 It was my mistake. 是我的错

It seems that xerces library is not included in SonarQube 4.x anymore. 似乎SonerQube 4.x不再包含xerces库。 Recompiling my plugin with sonar-plugin-api 4.0, maven finds xercesimpl and includes it to my plugin. maven使用sonar-plugin-api 4.0重新编译我的插件,找到了xercesimpl并将其包含到我的插件中。 Then, it works fine. 然后,它工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM