无法通过具有Jenkins构建和Maven项目的Sonar分析中的ClassLoader警告访问"XXX/XXX/XXX"类 [英] Class 'XXX/XXX/XXX ' is not accessible through the ClassLoader warning in Sonar analysis with Jenkins build and maven project
问题描述
我知道这是递归问题,但是我找不到解决问题的方法.
I know it's recurent question but I couldn't find a solution to my issue.
在 JENKINS 中,我在构建后进行了 SONAR 分析.当Soanar到达Java bytecode scan...
时,显示:WARN - Class '.../.../.../...' is not accessible through the ClassLoader
.
In JENKINS, I run a SONAR analysis after the build. When Soanar gets to Java bytecode scan...
it displays : WARN - Class '.../.../.../...' is not accessible through the ClassLoader
.
扫描是在 Maven 项目上进行的,Sonar继续在此消息中显示,并抛出了许多其他使用 Maven 依赖项的类.
The scan is on a Maven project, and Sonar keeps displayin this message throw many other classes that uses Maven dependancies.
声纳分析使用的是 SONAR-RUNNER .
我在许多帖子中看到,可以通过在sonar-project.properties
中添加sonar.librairies=/path/to/libraries/*jar
来解决此问题,但是使用 Maven ,依赖关系不会被分组在一个文件夹下. Jar 被分派到 Maven存储库下的不同文件夹下.
I saw in many posts, that the issue could be fixed by adding sonar.librairies=/path/to/libraries/*jar
in the sonar-project.properties
but with Maven , dependancies are not grouped under one folder. Jar's are dispatched under different folders under the maven-repositories.
那么,如何解决此问题以在没有这些警告的情况下扫描我的代码?
So how can I fix this issue to scan my code without these warnings ?
仅供参考:
詹金斯 1.555
声纳 4.2
声纳赛跑者 2.3
Java 1.7
Maven 3.04
堆栈跟踪:
09:23:55.605 INFO - Java bytecode scan...
09:23:55.646 WARN - Class 'org/springframework/context/ApplicationContext' is not accessible through the ClassLoader.
09:23:55.656 WARN - Class 'com/mongodb/MongoClient' is not accessible through the ClassLoader.
09:23:55.657 WARN - Class 'com/mongodb/DB' is not accessible through the ClassLoader.
09:23:55.661 WARN - Class 'org/springframework/context/ApplicationContext' is not accessible through the ClassLoader.
09:23:55.662 WARN - Class 'org/springframework/context/ApplicationContext' is not accessible through the ClassLoader.
...
09:23:55.749 WARN - Class 'org/apache/log4j/Logger' is not accessible through the ClassLoader.
09:23:55.773 INFO - Java bytecode scan done: 168 ms
编辑:
在jenkins build中运行mvn dependency:tree
:
Running mvn dependency:tree
in jenkins build :
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli)
[INFO] +- org.springframework:spring-context:jar:4.0.3.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:4.0.3.RELEASE:compile
[INFO] | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | +- org.springframework:spring-beans:jar:4.0.3.RELEASE:compile
[INFO] | +- org.springframework:spring-core:jar:4.0.3.RELEASE:compile
[INFO] | | \- commons-logging:commons-logging:jar:1.1.3:compile
[INFO] | \- org.springframework:spring-expression:jar:4.0.3.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:4.0.3.RELEASE:compile
[INFO] | \- org.springframework:spring-web:jar:4.0.3.RELEASE:compile
[INFO] +- org.springframework:spring-test:jar:4.0.3.RELEASE:test
[INFO] +- org.apache.poi:poi:jar:3.9:compile
[INFO] | \- commons-codec:commons-codec:jar:1.5:compile
...
...
[INFO] +- org.mockito:mockito-all:jar:1.9.5:test
[INFO] +- com.jayway.jsonpath:json-path:jar:0.9.1:test
[INFO] | \- net.minidev:json-smart:jar:1.2:test
[INFO] +- org.hamcrest:hamcrest-all:jar:1.3:test
[INFO] \- junit:junit:jar:4.11:test (scope not updated to compile)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
谢谢
推荐答案
由于Maven列出了缺少的类,因此您可能正在使用Jenkins插件来运行Sonar.我从未使用过此插件,但我猜想它并不了解Maven.因此,它无法从POM创建类路径,并且运行时确实缺少类.
Since Maven lists the missing classes, you're probably using the Jenkins plugin to run Sonar. I never used this plugin but my guess is that it doesn't know about Maven. Therefore, it can't create a classpath from the POM and the classes are really missing when it runs.
尝试使用Maven目标运行Sonar:mvn sonar:sonar
在配置后正确的Maven Sonar插件.
Try to run Sonar using the Maven goal: mvn sonar:sonar
after configuring the Sonar plugin for Maven correctly.
这篇关于无法通过具有Jenkins构建和Maven项目的Sonar分析中的ClassLoader警告访问"XXX/XXX/XXX"类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!