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.
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 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.
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?
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.