gpt4 book ai didi

java - org.sonar.api.utils.SonarException : Can not add twice the same measure on org. sonar.api.resources.File

转载 作者:搜寻专家 更新时间:2023-10-31 20:11:38 33 4
gpt4 key购买 nike

我有一个 Jenkins Job,它在由多个模块组成的 Maven 项目上运行 SonarRunner。当我配置 SonarRunner 以导入 Cobertura 覆盖率报告时,构建失败。

SonarQube Runner 2.4
Java 1.7.0_55 Oracle Corporation (64-bit)
Windows 7 6.1 amd64
INFO: Error stacktraces are turned on.
INFO: Runner configuration file: C:\Jenkins\tools\hudson.plugins.sonar.SonarRunnerInstallation\Sonar_Runner\conf\sonar-runner.properties
INFO: Project configuration file: NONE
INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent)
INFO: Work directory: C:\Jenkins\workspace\Sprint3\Application\.sonar
INFO: SonarQube Server 4.3
11:07:44.407 INFO - Load batch settings
11:07:44.609 INFO - User cache: C:\.sonar\cache
11:07:44.625 INFO - Install plugins
11:07:44.765 INFO - Install JDBC driver
11:07:44.781 WARN - H2 database should be used for evaluation purpose only
11:07:44.781 INFO - Create JDBC datasource for jdbc:h2:tcp://localhost/sonar
11:07:45.951 INFO - Initializing Hibernate
11:07:47.885 INFO - Load project settings
11:07:47.963 INFO - Apply project exclusions
11:07:48.229 INFO - ------------- Scan JmsUtils
11:07:48.229 INFO - Load module settings
11:07:49.508 INFO - Loading technical debt model...
11:07:49.523 INFO - Loading technical debt model done: 15 ms
11:07:49.523 INFO - Loading rules...
11:07:49.789 INFO - Loading rules done: 266 ms
11:07:49.804 INFO - Configure Maven plugins
11:07:49.976 INFO - Compare to previous analysis (2014-05-21)
11:07:50.007 INFO - Compare over 30 days (2014-04-21, analysis of 2014-05-08 15:55:35.699)
11:07:50.007 INFO - No quality gate is configured.
11:07:50.147 INFO - Base dir: C:\Jenkins\workspace\Sprint3\Application\JmsUtils
11:07:50.147 INFO - Working dir: C:\Jenkins\workspace\Sprint3\Application\.sonar\WSM_Application_JmsUtils
11:07:50.147 INFO - Source dirs: C:\Jenkins\workspace\Sprint3\Application\JmsUtils\src\main\java
11:07:50.147 INFO - Test dirs: C:\Jenkins\workspace\Sprint3\Application\JmsUtils\src\test\java
11:07:50.147 INFO - Binary dirs: C:\Jenkins\workspace\Sprint3\Application\JmsUtils\target\classes
11:07:50.147 INFO - Source encoding: windows-1252, default locale: en_US
11:07:50.147 INFO - Index files
11:07:50.350 INFO - 4 files indexed
11:07:50.428 INFO - Quality profile for java: WSM way with Findbugs - Server Code
11:07:50.444 INFO - Sensor JavaSquidSensor...
11:07:50.491 INFO - Java Main Files AST scan...
11:07:50.506 INFO - 2 source files to be analyzed
11:07:50.740 INFO - 2/2 source files analyzed
11:07:50.756 INFO - Java Main Files AST scan done: 265 ms
11:07:50.756 INFO - Java bytecode scan...
11:07:50.787 WARN - Class 'javax/jms/Session' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'javax/jms/Connection' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'org/apache/log4j/Logger' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'javax/jms/Session' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'javax/jms/MessageProducer' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'javax/jms/Message' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'org/apache/log4j/Logger' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'javax/jms/ConnectionFactory' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'javax/jms/Connection' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'javax/jms/Session' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'javax/jms/Session' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'javax/jms/Session' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'org/apache/log4j/Logger' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'org/apache/log4j/Logger' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'mil/navy/aif/domain/AuditRecord' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'mil/navy/aif/domain/AuditRecord' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'mil/navy/aif/domain/AuditRecord' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'mil/navy/aif/domain/AuditRecord' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'mil/navy/aif/domain/AuditRecord' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'mil/navy/aif/domain/AuditRecord' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader.
11:07:50.787 WARN - Class 'org/apache/log4j/Logger' is not accessible through the ClassLoader.
11:07:50.803 WARN - Class 'org/apache/log4j/Logger' is not accessible through the ClassLoader.
11:07:50.803 INFO - Java bytecode scan done: 47 ms
11:07:50.803 INFO - Java Test Files AST scan...
11:07:50.803 INFO - 2 source files to be analyzed
11:07:50.849 INFO - Java Test Files AST scan done: 46 ms
11:07:50.849 INFO - 2/2 source files analyzed
11:07:50.849 INFO - Package design analysis...
11:07:50.865 INFO - Package design analysis done: 16 ms
11:07:50.881 INFO - Sensor JavaSquidSensor done: 437 ms
11:07:50.881 INFO - Sensor QProfileSensor...
11:07:50.881 INFO - Sensor QProfileSensor done: 0 ms
11:07:50.881 INFO - Sensor FindbugsSensor...
11:07:50.896 INFO - Execute Findbugs 2.0.3...
11:07:52.269 INFO - Findbugs output report: C:\Jenkins\workspace\Sprint3\Application\.sonar\WSM_Application_JmsUtils\findbugs-result.xml
The following classes needed for analysis were missing:
javax.jms.Session
javax.jms.Connection
org.apache.log4j.Logger
javax.jms.ConnectionFactory
javax.jms.Message
javax.jms.MessageProducer
mil.navy.aif.domain.AuditRecord
javax.jms.JMSException
javax.jms.Topic
javax.jms.Destination
11:07:54.609 INFO - Execute Findbugs 2.0.3 done: 3698 ms
11:07:54.609 INFO - Sensor FindbugsSensor done: 3728 ms
11:07:54.609 INFO - Sensor JaCoCoItSensor...
11:07:54.609 INFO - Project coverage is set to 0% as no JaCoCo execution data has been dumped: C:\Jenkins\workspace\Sprint3\Application\JmsUtils\target\jacoco-it.exec
11:07:54.672 INFO - Sensor JaCoCoItSensor done: 63 ms
11:07:54.672 INFO - Sensor JaCoCoOverallSensor...
11:07:54.672 INFO - Sensor JaCoCoOverallSensor done: 0 ms
11:07:54.672 INFO - Sensor CoberturaSensor...
11:07:54.687 INFO - parsing C:\Jenkins\workspace\Sprint3\Application\JmsUtils\target\site\cobertura\coverage.xml
11:07:54.765 INFO - Sensor CoberturaSensor done: 93 ms
11:07:54.765 INFO - Sensor CpdSensor...
11:07:54.765 INFO - SonarEngine is used for java
11:07:54.765 INFO - Cross-project analysis disabled
11:07:54.812 INFO - Sensor CpdSensor done: 47 ms
11:07:54.812 INFO - Sensor InitialOpenIssuesSensor...
11:07:54.890 INFO - Sensor InitialOpenIssuesSensor done: 78 ms
11:07:54.890 INFO - Sensor ProfileEventsSensor...
11:07:54.906 INFO - Sensor ProfileEventsSensor done: 16 ms
11:07:54.906 INFO - Sensor ProjectLinksSensor...
11:07:54.906 INFO - Sensor ProjectLinksSensor done: 0 ms
11:07:54.906 INFO - Sensor VersionEventsSensor...
11:07:54.921 INFO - Sensor VersionEventsSensor done: 15 ms
11:07:54.921 INFO - Sensor FileHashSensor...
11:07:54.921 INFO - Sensor FileHashSensor done: 0 ms
11:07:54.921 INFO - Sensor SurefireSensor...
11:07:54.921 INFO - parsing C:\Jenkins\workspace\Sprint3\Application\JmsUtils\target\surefire-reports
11:07:54.937 INFO - Sensor SurefireSensor done: 16 ms
11:07:54.937 INFO - Sensor JaCoCoSensor...
11:07:54.937 INFO - Project coverage is set to 0% as no JaCoCo execution data has been dumped: C:\Jenkins\workspace\Sprint3\Application\JmsUtils\target\jacoco.exec
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 11.513s
Final Memory: 21M/674M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at org.sonar.runner.Main.executeTask(Main.java:70)
at org.sonar.runner.Main.execute(Main.java:59)
at org.sonar.runner.Main.main(Main.java:53)
Caused by: org.sonar.api.utils.SonarException: Can not add twice the same measure on org.sonar.api.resources.File@318c8090[key=src/main/java/mil/navy/wsm/jmsutils/Auditor.java,deprecatedKey=mil.navy.wsm.jmsutils.Auditor,path=src/main/java/mil/navy/wsm/jmsutils/Auditor.java,dir=mil/navy/wsm/jmsutils,filename=Auditor.java,language=Java]: org.sonar.api.measures.Measure@7f4c8759[id=<null>,metricKey=lines_to_cover,metric=Metric[id=38,formula=<null>,key=lines_to_cover,description=Lines to cover,type=INT,direction=1,domain=Tests,name=Lines to cover,qualitative=false,userManaged=false,enabled=true,origin=JAV,worstValue=<null>,bestValue=<null>,optimizedBestValue=false,hidden=false,deleteHistoricalData=false],value=28.0,data=<null>,description=<null>,alertStatus=<null>,alertText=<null>,tendency=<null>,date=<null>,variation1=<null>,variation2=<null>,variation3=<null>,variation4=<null>,variation5=<null>,url=<null>,characteristic=<null>,requirement=<null>,personId=<null>,persistenceMode=FULL]
at org.sonar.batch.index.Bucket.addMeasure(Bucket.java:95)
at org.sonar.batch.index.DefaultIndex.addMeasure(DefaultIndex.java:209)
at org.sonar.batch.DefaultSensorContext.saveMeasure(DefaultSensorContext.java:168)
at org.sonar.plugins.jacoco.JaCoCoSensor$UnitTestsAnalyzer.saveMeasures(JaCoCoSensor.java:86)
at org.sonar.plugins.jacoco.AbstractAnalyzer.readExecutionData(AbstractAnalyzer.java:151)
at org.sonar.plugins.jacoco.AbstractAnalyzer.analyse(AbstractAnalyzer.java:107)
at org.sonar.plugins.jacoco.JaCoCoSensor.analyse(JaCoCoSensor.java:61)
at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:79)
at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:70)
at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:131)
at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:178)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:199)
at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:194)
at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:192)
at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:187)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:56)
at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:44)
at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:82)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
at org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapContainer.java:175)
at org.sonar.batch.bootstrap.BootstrapContainer.doAfterStart(BootstrapContainer.java:163)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
at org.sonar.batch.bootstrapper.Batch.startBatch(Batch.java:92)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:74)
at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
... 9 more
ERROR:
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
Build step 'Invoke Standalone Sonar Analysis' marked build as failure
Finished: FAILURE

以下是我在 Jenkins 中为 SonarRunner 分析配置的项目属性:

sonar.projectKey=WSM:Application
sonar.projectName=Application
sonar.projectVersion=1.0.2.4-SNAPSHOT
sonar.sources=src/main/java
sonar.binaries=target/classes
sonar.tests=src/test/java
sonar.junit.reportsPath=target/surefire-reports
sonar.java.coveragePlugin=cobertura
sonar.cobertura.reportPath=target/site/cobertura/coverage.xml
sonar.modules=JmsUtils,MsgGenerationUtils,WsmCopyAsNew,WsmGeomCreator,WsmGoldMsgParser,WsmJpa,WsmMsgGenerator

如果我删除 sonar.java.coveragePluginsonar.cobertura.reportPath 属性,构建会成功,但是我不会有任何覆盖率指标。

我认为问题的发生是因为 Cobertura 和 JaCoCo 试图测量相同的文件时存在冲突。您可以在堆栈跟踪中看到错误涉及 JaCoCo 传感器。我根本不想使用 JaCoCo。

Jenkins 版本:1.560
Jenkins Sonar 插件版本:2.1
Sonar 版本:4.3
Sonar Cobertura 插件版本:1.6.1
Sonar Java 插件版本:2.2

最佳答案

2.2 版的解决方法。就是要设置

sonar.jacoco.reportMissing.force.zero=False

在 sonar-project.properties 中。

关于java - org.sonar.api.utils.SonarException : Can not add twice the same measure on org. sonar.api.resources.File,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23791921/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com