2

How do I resolve the following TeamCity error from the build log? The build fails with "Failed to parse xml report".

[Surefire report watcher] Parsing errors
[00:34:17]  [Parsing errors] Failed to parse 1 report
[00:34:17]  [Parsing errors] rose/target/surefire-reports/TEST-TestSuite.xml: An invalid XML character (Unicode: 0xffff) was found in the CDATA section.
[00:34:17]  [Parsing errors] jetbrains.buildServer.util.XmlXppAbstractParser$3: An invalid XML character (Unicode: 0xffff) was found in the CDATA section.
    at jetbrains.buildServer.util.XmlXppAbstractParser.parse(XmlXppAbstractParser.java:39)
    at jetbrains.buildServer.util.XmlXppAbstractParser.parse(XmlXppAbstractParser.java:31)
    at jetbrains.buildServer.xmlReportPlugin.parsers.antJUnit.AntJUnitReportParser.parse(AntJUnitReportParser.java:179)
    at jetbrains.buildServer.xmlReportPlugin.ParseReportCommand.run(ParseReportCommand.java:62)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.xml.sax.SAXParseException; lineNumber: 1489; columnNumber: 74; An invalid XML character (Unicode: 0xffff) was found in the CDATA section.
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at jetbrains.buildServer.util.XmlXppAbstractParser.parseWithSAX(XmlXppAbstractParser.java:240)
    at jetbrains.buildServer.util.XmlXppAbstractParser.parse(XmlXppAbstractParser.java:37)
    ... 8 more

The XML file (saved as an artifact) opens properly in Notepad++, but I get the following error when I click to open it in Chrome:

This page contains the following errors:
error on line 86 at column 18: Input is not proper UTF-8, indicate encoding !
Bytes: 0xEF 0xBF 0xBF 0x0A

If it helps, the issue seems to be caused after using Cucumber with a TestNG wrapper since I have both JUnit and TestNG as dependencies.

Leponzo
  • 624
  • 1
  • 8
  • 20
  • At this point you'd try to create a minimal reproducer, determine which component is responsible and file a bug report with that reproducer. – M.P. Korstanje Jan 07 '21 at 05:25
  • Have you solved your problem since 2021 ? I'm facing what looks like a similar issue, and hints would be great! – Ulysse BN Mar 10 '22 at 11:14
  • @UlysseBN Yes, it was a simple solution in my case (just posted an answer). – Leponzo Mar 10 '22 at 11:21

1 Answers1

1

It turns out the 0xffff character actually was being generated in the code since it was saved as a constant somewhere. For future readers, I suggest searching \uffff in your code and avoiding printing it in your tests.

Leponzo
  • 624
  • 1
  • 8
  • 20