0

I'm trying to deploy my project with Jenkins, but I'm getting the following error always:

org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.

I have tried a lot of solutions, but I can't solve this problem.

  • My xml file has an UTF-8 encoding.
  • I have read my xml file with a hex editor and it has no spaces at the beginning of the document.
  • I have tried to create a new text file and copy the content of the xml file into the new document and change the extension from 'txt' to 'xml'.

My xml document starts this way:

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <artifactId>...</artifactId>
        <groupId>...</groupId>
        <version>...</version>
    </parent>

    <groupId>...</groupId>
    <artifactId>...</artifactId>
    <version>...</version>
    <description>...</description>
    <packaging>...</packaging>
    <name>...</name>

Could you help me?

2 Answers2

1

Almost certain this is problem with file encoding, probably due to BOM, for details see this answer.

You could do 2 things:

  1. remove BOM from pom.xml and encode it using same encoding as your Jenkins' JVM is configured with

  2. Configure Jenkins' JVM to use different encoding, see this answer for details

rkosegi
  • 14,165
  • 5
  • 50
  • 83
0

The message "Content is not allowed in prolog" generally means that Xerces started reading the content of the file and the first thing it found was something other than <.

A very common cause of the problem is that you aren't parsing the content you think you are. For example, it happens when you supply the URI of a file to an API that actually expects the content of the file.

So the solution may be that you are invoking the parser incorrectly. Of course we can't tell whether that applies here, because you haven't told us how you are invoking the parser.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164