# Ant sonarcheck jacoco coverage XML issues

**URL:** <https://community.sonarsource.com/t/ant-sonarcheck-jacoco-coverage-xml-issues/28122>\
**Category:** SonarQube Server / Community Build\
**Tags:** ant, jacoco, sonarqube\
**Created:** [July 15, 2020, 1:14am UTC](https://community.sonarsource.com/t/ant-sonarcheck-jacoco-coverage-xml-issues/28122 "2020-07-15T01:14:36Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mayuresh](https://avatars.discourse-cdn.com/v4/letter/m/f19dbf/32.png) [@mayuresh](https://community.sonarsource.com/u/mayuresh)\
**Post date:** [July 15, 2020, 1:14am UTC](https://community.sonarsource.com/t/ant-sonarcheck-jacoco-coverage-xml-issues/28122/1 "2020-07-15T01:14:36Z")

</div>

Hi,  
We just upgraded the sonarqube to 8.4 from 7.5 as we were not able to install any new tools in it. After the upgrade we ran the analysis for our SAP ant based project and seeing below errors while uploading the coverage to sonarqube.

**sonar:sonar] Coverage report ‘/data/log/jacoco/reports/jacoco.xml’ could not be read/imported. Error: {}**  
**[sonar:sonar] java.lang.IllegalStateException: Failed to parse JaCoCo XML report: /data/hybris/hybris/log/jacoco/reports/jacoco.xml**  
[sonar:sonar] at org.sonar.plugins.jacoco.XmlReportParser.parse(XmlReportParser.java:108)  
[sonar:sonar] at org.sonar.plugins.jacoco.JacocoSensor.importReport(JacocoSensor.java:70)  
[sonar:sonar] at org.sonar.plugins.jacoco.JacocoSensor.importReports(JacocoSensor.java:62)  
[sonar:sonar] at org.sonar.plugins.jacoco.JacocoSensor.execute(JacocoSensor.java:47)  
[sonar:sonar] at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)  
[sonar:sonar] at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)  
.  
.  
…  
…  
**[sonar:sonar] Caused by: com.ctc.wstx.exc.WstxIOException: Input length = 1**  
[sonar:sonar] at com.ctc.wstx.stax.WstxInputFactory.doCreateSR(WstxInputFactory.java:550)  
[sonar:sonar] at com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:605)  
[sonar:sonar] at com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:658)  
[sonar:sonar] at com.ctc.wstx.stax.WstxInputFactory.createXMLStreamReader(WstxInputFactory.java:338)  
[sonar:sonar] at org.sonar.plugins.jacoco.XmlReportParser.parse(XmlReportParser.java:51)  
[sonar:sonar] … 63 common frames omitted  
**[sonar:sonar] Caused by: java.nio.charset.MalformedInputException: Input length = 1**  
[sonar:sonar] at java.base/java.nio.charset.CoderResult.throwException(CoderResult.java:274)  
[sonar:sonar] at java.base/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:339)  
[sonar:sonar] at java.base/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)  
[sonar:sonar] at java.base/java.io.InputStreamReader.read(InputStreamReader.java:185)  
[sonar:sonar] at java.base/java.io.BufferedReader.fill(BufferedReader.java:161)  
[sonar:sonar] at java.base/java.io.BufferedReader.read1(BufferedReader.java:212)  
[sonar:sonar] at java.base/java.io.BufferedReader.read(BufferedReader.java:287)  
[sonar:sonar] at com.ctc.wstx.io.ReaderBootstrapper.initialLoad(ReaderBootstrapper.java:250)  
[sonar:sonar] at com.ctc.wstx.io.ReaderBootstrapper.bootstrapInput(ReaderBootstrapper.java:133)  
[sonar:sonar] at com.ctc.wstx.stax.WstxInputFactory.doCreateSR(WstxInputFactory.java:545)  
[sonar:sonar] … 67 common frames omitted  
**[sonar:sonar] Sensor JaCoCo XML Report Importer [jacoco] (done) | time=2ms**

is anyone seen this issue. I read that this could be resolved by setting **“sonar.sourceEncoding=UTF-8”** but its not helping.

Thanks,  
Mayuresh

---

<div class="post-metadata">

**Author:** ![mayuresh](https://avatars.discourse-cdn.com/v4/letter/m/f19dbf/32.png) [@mayuresh](https://community.sonarsource.com/u/mayuresh)\
**Post date:** [July 17, 2020, 12:07am UTC](https://community.sonarsource.com/t/ant-sonarcheck-jacoco-coverage-xml-issues/28122/2 "2020-07-17T00:07:13Z")

</div>

Checking if anyone have seen the similar issues?

---

<div class="post-metadata">

**Author:** ![Antoine](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/antoine/32/1316_2.png) [@Antoine](https://community.sonarsource.com/u/Antoine)\
**Post date:** [July 17, 2020, 6:30am UTC](https://community.sonarsource.com/t/ant-sonarcheck-jacoco-coverage-xml-issues/28122/3 "2020-07-17T06:30:21Z")

</div>

Hello @mayuresh,

I’m quite sure `sonar.sourceEncoding` only applies to source files, not reports, so I don’t think this would make any difference.

This Java exception `java.nio.charset.MalformedInputException` is likely about some encoding issue. The default JaCoCo [outputEncoding](https://www.eclemma.org/jacoco/trunk/doc/report-mojo.html#outputEncoding) is UTF-8, is it something that you changed somehow?  
You should open and review your XML report to check if it’s valid or what is going on with it.

Cheers

---

<div class="post-metadata">

**Author:** ![mayuresh](https://avatars.discourse-cdn.com/v4/letter/m/f19dbf/32.png) [@mayuresh](https://community.sonarsource.com/u/mayuresh)\
**Post date:** [July 30, 2020, 1:36am UTC](https://community.sonarsource.com/t/ant-sonarcheck-jacoco-coverage-xml-issues/28122/4 "2020-07-30T01:36:52Z")

</div>

Hi Antonie,  
I checked the XML and i am seeing some weird data like below.

5\>ô^K^@2com/Stock"^A^@^@ª^B^Q^EñÍßÚ¼Mm^@4com/Enum ^?^@Àv^AÀÀ^P^G^P^^@^@^Ast\<82\>Ã®^@^@^Ast\<86\>õÏ^Q\<97\>pV«^Qø\<9c\>!^@Zcom/Strategy^Y^C^@^@^A^Q\<87\>^X^V3ä,1^E^@acom/Converter^B^A^Q^X\<89\>\<92\>Ù#F]^S^@Pcom DefaultUserPreferenceService\<8e\>^C^C^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^Q®h\<93\>&ÿ\<9a\>^BÑ^@Tcom/facades/bazaarvoice/impl/\<97\>^A^G^@^@^@^@^@^@^@^@@^A^@^@^@^@^@^@XU^Qü¿\<94\>¦y^NÝ^R^@Acom/impl/DefaultFacetedService[^C^@^@^@^@^@^@^@^@^@^@^@^Q¥´ã\<8a\>\e2^@7com/

---

<div class="post-metadata">

**Author:** ![dmeneses](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/dmeneses/32/2933_2.png) [@dmeneses](https://community.sonarsource.com/u/dmeneses)\
**Post date:** [July 30, 2020, 5:47pm UTC](https://community.sonarsource.com/t/ant-sonarcheck-jacoco-coverage-xml-issues/28122/5 "2020-07-30T17:47:06Z")

</div>

That looks like something binary. Are you sure it’s not the JaCoCo data file that needs to be processed by JaCoCo’s report task to produce the XML report?

---

<div class="post-metadata">

**Author:** ![mayuresh](https://avatars.discourse-cdn.com/v4/letter/m/f19dbf/32.png) [@mayuresh](https://community.sonarsource.com/u/mayuresh)\
**Post date:** [August 3, 2020, 2:18am UTC](https://community.sonarsource.com/t/ant-sonarcheck-jacoco-coverage-xml-issues/28122/6 "2020-08-03T02:18:45Z")

</div>

Below is my configuration that i am using to process.

#Sonar Properties

```auto
sonar.projectName=<NAME>

sonar.projectKey=<KEY/>

sonar.host.url=<URL>

sonar.login=<API_KEY>

sonar.language=java

clustermode=false

sonar.verbose=true

sonar.sourceEncoding=UTF-8

sonar.java.coveragePlugin=jacoco

sonar.coverage.jacoco.xmlReportPaths=<PATH>/reports/jacoco.xml

sonar.extensions=extension1,extension2,extension3,extension4

sonar.inclusions=**/*.java

sonar.exclusions= **/jalo/** /*.java, **/constants/** /*.java, **/dto/** /*.java, **/*DTO.java,** /dtos/ **/*.java,** /integ/webservices/ **/*.java,** /*Standalone.java, **/gensrc/** /*.java, **/request/** /*.java, **/result/** /*.java, **/data/** /*.java,*/*Controller.java, **/Jalo/** /*.java,**/*Form.java

sonar.coverage.exclusions=*WebHelper.java, **/jalo/** /*.java, **/constants/** /*.java, **/dto/** /*.java, **/*DTO.java,** /dtos/ **/*.java,** /integ/webservices/ **/*.java,** /*Standalone.java, **/gensrc/** /*.java, **/request/** /*.java, **/result/** /*.java, **/data/** /*.java,*/*Controller.java, **/Jalo/** /*.java, **/*Form.java,** /*DTO.java

sonar.web.file.suffixes=.jsp,.tag

sonar.junit.reportsPath=<path_to_junit>/junit

standalone.javaoptions=-javaagent:${BIN_DIR}/platform/resources/ant/sonar/lib/jacocoagent.jar=destfile=<PATH>/reports/jacoco.xml,append=true,excludes=com.google.*:com.sun.*:de.hybris.*:org.mockito.*:org.junit.*:org.apache.*,includes=<our_package>

```

---

<div class="post-metadata">

**Author:** ![dmeneses](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/dmeneses/32/2933_2.png) [@dmeneses](https://community.sonarsource.com/u/dmeneses)\
**Post date:** [August 3, 2020, 7:48pm UTC](https://community.sonarsource.com/t/ant-sonarcheck-jacoco-coverage-xml-issues/28122/7 "2020-08-03T19:48:54Z")

</div>

The properties aren’t necessarily the problem. It looks like the file `<PATH>/reports/jacoco.xml` is a binary file. It should be the XML report that the JaCoCo’s `report` task outputs. I’d check if JaCoCo is correctly set up to install the agent during the execution of the tests (producing a binary data file) **and** that it processes that file to produce the XML report that should then be imported with the SonarQube scanner.

---

<div class="post-metadata">

**Author:** ![mayuresh](https://avatars.discourse-cdn.com/v4/letter/m/f19dbf/32.png) [@mayuresh](https://community.sonarsource.com/u/mayuresh)\
**Post date:** [August 19, 2020, 5:10am UTC](https://community.sonarsource.com/t/ant-sonarcheck-jacoco-coverage-xml-issues/28122/8 "2020-08-19T05:10:23Z")

</div>

Able to fix the coverage issue using jacococli in the build step…

java -jar jacococli.jar report /reports/jacoco.exec --classfiles “/aaa/classes/” --classfiles “/abc/classes” --xml /reports/jacoco.xml

then upload the xml report using sonar.coverage.jacoco.xmlReportPaths.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [August 26, 2020, 5:10am UTC](https://community.sonarsource.com/t/ant-sonarcheck-jacoco-coverage-xml-issues/28122/9 "2020-08-26T05:10:27Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
