Issue
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.
Solution
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.
Answered By - Leponzo
Answer Checked By - Mary Flores (JavaFixing Volunteer)