当前位置: 首页 > 知识库问答 >
问题:

IllegalStateException:无法解析JaCoCo XML报告:JaCoCo.exec

湛同
2023-03-14

我试图发布由Jacoco插件-Jacoco.exec生成的覆盖报告。但我得到以下例外与提到的声纳和Jacoco配置。

SonarCube版本6.7.7

[ERROR] Coverage report 'jacoco.exec' could not be read/imported. Error: {}
java.lang.IllegalStateException: Failed to parse JaCoCo XML report: jacoco.exec
    at org.sonar.plugins.jacoco.XmlReportParser.parse(XmlReportParser.java:96)
    at org.sonar.plugins.jacoco.JacocoSensor.importReport(JacocoSensor.java:73)
    at org.sonar.plugins.jacoco.JacocoSensor.importReports(JacocoSensor.java:64)
    at org.sonar.plugins.jacoco.JacocoSensor.execute(JacocoSensor.java:48)
    at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)
    at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:88)
    at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:82)
    at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:68)
    at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:88)
    at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:177)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
    at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:291)
    at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:286)
    at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:264)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
    at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
    at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:84)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
    at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:121)
    at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:71)
    at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
    at com.sun.proxy.$Proxy24.execute(Unknown Source)
    at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
    at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
    at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.java:65)
    at org.sonarsource.scanner.maven.SonarQubeMojo.execute(SonarQubeMojo.java:104)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: javax.xml.stream.XMLStreamException: java.nio.charset.MalformedInputException: Input length = 1
    at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.setInputSource(XMLStreamReaderImpl.java:212)
    at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.<init>(XMLStreamReaderImpl.java:184)
    at com.sun.xml.internal.stream.XMLInputFactoryImpl.getXMLStreamReaderImpl(XMLInputFactoryImpl.java:262)
    at com.sun.xml.internal.stream.XMLInputFactoryImpl.createXMLStreamReader(XMLInputFactoryImpl.java:134)
    at org.sonar.plugins.jacoco.XmlReportParser.parse(XmlReportParser.java:46)
    ... 56 common frames omitted
Caused by: java.nio.charset.MalformedInputException: Input length = 1
    at java.nio.charset.CoderResult.throwException(CoderResult.java:281)
    at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:339)
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
    at java.io.InputStreamReader.read(InputStreamReader.java:184)
    at java.io.BufferedReader.fill(BufferedReader.java:161)
    at java.io.BufferedReader.read1(BufferedReader.java:212)
    at java.io.BufferedReader.read(BufferedReader.java:286)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1895)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.arrangeCapacity(XMLEntityScanner.java:1761)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipString(XMLEntityScanner.java:1829)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$XMLDeclDriver.next(XMLDocumentScannerImpl.java:749)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
    at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.setInputSource(XMLStreamReaderImpl.java:202)
    ... 60 common frames omitted
<sonar.jacoco.reportPath>target/jacoco.exec</sonar.jacoco.reportPath>
<sonar.jacoco.itReportPath>target/jacoco-it.exec</sonar.jacoco.itReportPath>
<sonar.language>java</sonar.language>
<sonar.verbose>true</sonar.verbose>
<sonar.java.source>8</sonar.java.source>
      <org.jacoco.version>0.8.1</org.jacoco.version>
      <profile>
            <id>sonar-coverage</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.sonarsource.scanner.maven</groupId>
                    <artifactId>sonar-maven-plugin</artifactId>
                    <version>3.3.0.603</version>
                </plugin>
            </plugins>
        </build>
    </profile>

    <profile>
        <id>jacoco</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>${org.jacoco.version}</version>
                    <configuration>
                        <append>true</append>
                    </configuration>
                    <executions>
                        <execution>
                            <id>agent-for-unit-test</id>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>agent-for-integration-test</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>prepare-agent-integration</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>jacoco-site</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>    

共有1个答案

辛盛
2023-03-14

java.lang.IllegalStateException:未能解析JaCoCo XML报表:JaCoCo.exec
...
原因:javax.XML.stream.xmlStreamException:java.nio.charset.MalFormedInputException:输入长度=1

该错误表示在解析XML时发现了不受支持的字符,并且文件为jacoco.exec。这是因为jacoco.exec是二进制的,而不是XML。

此外,Sonar已经不支持jacoco.exec.
,我建议您遵循covery-test-data-import-jacoco-covery-report-in-xml格式。从上面的链接:

默认情况下,生成的报告将保存在target/site/jacoco/jacoco.xml下;此位置将由sonar-jacoco插件自动检查,因此无需进一步配置。只要发射mvn声纳:声纳像往常一样,报告就会被接收。

 类似资料:
  • 在调试模式下运行服务器时,我会在下面发布错误日志。请帮我理解这份报告

  • 有个问题。Intellij IDEA在我从事一个包含Tapestry框架的项目时,经常出现“无法解决符号”错误。此错误仅在*中出现。tml文件。我注意到的另一件事是,这个错误会有选择性地出现。例如,IDEA识别

  • 我是BIRT的新手,今天已经为Java和报表开发人员下载了Eclipse IDE。 在完成了一个教程之后,当我准备好预览我的报告时,我点击了“在Web Viewer上查看报告”和许多其他选项,但它总是为我启动Notepad+。 我的IDE有问题吗? 请指教。谢谢你抽出时间。 注意到错误日志中有一些错误,不确定这是否会影响报表的预览: java.lang.NullPointerException

  • 本文向大家介绍XHProf报告字段含义的解析,包括了XHProf报告字段含义的解析的使用技巧和注意事项,需要的朋友参考一下 Function Name:方法名称。 Calls:方法被调用的次数。 Calls%:方法调用次数在同级方法总数调用次数中所占的百分比。 Incl.Wall Time(microsec):方法执行花费的时间,包括子方法的执行时间。(单位:微秒) IWall%:方法执行花费的时

  • 上面的代码用于生成allure报告并运行测试,它运行并生成reports-allure-results中的一个文件夹,其中包含JSON文件。见下方截图

  • 这是我在执行Spring Boot应用程序时得到的错误消息: