Class not found error when running sonarrunner

喜你入骨 提交于 2019-12-02 07:19:11

问题


I am getting class not found error. The the class is not accessible through class loader and an error is being prompt when running the sonarrunner from gradle.

These classes are included as dependencies in compile time in gradle and gradle build works fine. How to include these classes for sonar ?

    14:53:24.322 INFO  - Load module settings
14:53:24.335 INFO  - Base dir: /Users/srao1/Documents/GradleTest/lds_warehouse/lds_warehouse_base
14:53:24.335 INFO  - Working dir: /Users/srao1/Documents/GradleTest/lds_warehouse/build/sonar/lds_warehouse_lds_warehouse_base
14:53:24.336 INFO  - Source paths: src
14:53:24.336 INFO  - Test paths: test
14:53:24.336 INFO  - Binary dirs: build/classes/main
14:53:24.336 INFO  - Source encoding: UTF-8, default locale: en_US
14:53:24.336 INFO  - Index files
14:53:24.444 INFO  - 50 files indexed
14:53:24.593 INFO  - Quality profile for java: Sonar way
14:53:24.604 INFO  - Sensor JavaSquidSensor
14:53:24.620 WARN  - sonar.binaries and sonar.libraries are deprecated since version 2.5 of sonar-java-plugin, please use sonar.java.binaries and sonar.java.libraries instead
14:53:24.628 INFO  - Java Main Files AST scan...
14:53:24.628 INFO  - 45 source files to be analyzed
14:53:25.070 ERROR - Class not found: com.lim.dw.dao.base.bean.WarehouseFeed
14:53:25.070 ERROR - Class not found: com.lim.dw.dao.base.bean.PhaseTimer
14:53:32.459 WARN  - Class 'com/lim/lds/LdsDataFeed' is not accessible through the ClassLoader.
14:53:32.459 WARN  - Class 'com/lim/lds/LdsDataFeed' is not accessible through the ClassLoader.
14:53:32.459 WARN  - Class 'com/lim/logger/Logger' is not accessible through the ClassLoader.
14:53:32.459 WARN  - Class 'com/lim/logger/Logger' is not accessible through the ClassLoader.
14:53:32.477 INFO  - Java bytecode scan done: 162 ms
14:53:32.477 INFO  - Java Test Files AST scan...
14:53:32.477 INFO  - 5 source files to be analyzed
14:53:32.727 INFO  - Java Test Files AST scan done: 250 ms
14:53:32.728 INFO  - 5/5 source files have been analyzed
14:53:32.728 INFO  - Package design analysis...
14:53:32.800 INFO  - Package design analysis done: 72 ms
14:53:32.889 INFO  - Sensor JavaSquidSensor (done) | time=8285ms
14:53:32.889 INFO  - Sensor Lines Sensor
14:53:32.892 INFO  - Sensor Lines Sensor (done) | time=3ms
14:53:32.892 INFO  - Sensor QProfileSensor
14:53:32.894 INFO  - Sensor QProfileSensor (done) | time=2ms
14:53:32.904 INFO  - Sensor InitialOpenIssuesSensor
14:53:33.016 INFO  - Sensor InitialOpenIssuesSensor (done) | time=112ms
14:53:33.016 INFO  - Sensor ProjectLinksSensor
14:53:33.018 INFO  - Sensor ProjectLinksSensor (done) | time=2ms
14:53:33.018 INFO  - Sensor VersionEventsSensor
14:53:33.023 INFO  - Sensor VersionEventsSensor (done) | time=5ms
14:53:33.023 INFO  - Sensor SurefireSensor
14:53:33.023 INFO  - parsing /Users/srao1/Documents/GradleTest/lds_warehouse/lds_warehouse_base/target/surefire-reports
14:53:33.023 ERROR - Reports path not found or is not a directory: /Users/srao1/Documents/GradleTest/lds_warehouse/lds_warehouse_base/target/surefire-reports
14:53:33.023 INFO  - Sensor SurefireSensor (done) | time=0ms
14:53:33.023 INFO  - Sensor JaCoCoOverallSensor
14:53:33.037 WARN  - You are not using the latest JaCoCo binary format version, please consider upgrading to latest JaCoCo version.
14:53:33.037 INFO  - Analysing /Users/srao1/Documents/GradleTest/lds_warehouse/lds_warehouse_base/build/jacoco/jacocoTest.exec
14:53:33.072 WARN  - You are not using the latest JaCoCo binary format version, please consider upgrading to latest JaCoCo version.
14:53:33.072 INFO  - Analysing /Users/srao1/Documents/GradleTest/lds_warehouse/build/sonar/lds_warehouse_lds_warehouse_base/jacoco-overall.exec
14:53:33.234 INFO  - No information about coverage per test.
14:53:33.234 INFO  - Sensor JaCoCoOverallSensor (done) | time=211ms
14:53:33.234 INFO  - Sensor SCM Sensor
14:53:33.234 INFO  - No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
14:53:33.234 INFO  - Sensor SCM Sensor (done) | time=0ms
14:53:33.234 INFO  - Sensor JaCoCoSensor
14:53:33.236 WARN  - You are not using the latest JaCoCo binary format version, please consider upgrading to latest JaCoCo version.
14:53:33.236 INFO  - Analysing /Users/srao1/Documents/GradleTest/lds_warehouse/lds_warehouse_base/build/jacoco/jacocoTest.exec
14:53:33.306 INFO  - No information about coverage per test.
14:53:33.306 INFO  - Sensor JaCoCoSensor (done) | time=72ms
14:53:33.306 INFO  - Sensor CPD Sensor
14:53:33.306 INFO  - JavaCpdEngine is used for java
14:53:33.307 INFO  - Cross-project analysis disabled
14:53:33.545 INFO  - Sensor CPD Sensor (done) | time=239ms
14:53:33.546 INFO  - No quality gate is configured.
14:53:33.549 INFO  - Compare to previous analysis (2015-07-23)
14:53:33.550 INFO  - Compare over 30 days (2015-06-24, analysis of Wed Jul 22 16:29:23 CDT 2015)
14:53:33.716 INFO  - Execute decorators...

回答1:


To perform source code analysis the SQ Java plugin needs bytecode in addition to the source code. Bytecode location for source files is provided thanks to properties sonar.java.binaries and sonar.java.test.binaries. Bytecode (or JAR) locations for third party libs is provided by properties sonar.java.libraries and sonar.java.test.libraries.

If you don't provide correctly those properties then you'll see some 'Class not found' errors. That doesn't prevent to complete the analysis but many SQ Java rules will probably not work and not detect any issue.

(Partial) example: sonar-runner -Dsonar.sources=src -Dsonar.java.binaries=bin/classes -Dsonar.java.libraries=libs/*.jar



来源:https://stackoverflow.com/questions/31593240/class-not-found-error-when-running-sonarrunner

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!