SAXParseException: Content not allowed in prolog

I need to add the following file to the Tomcat / conf directory:

<?xml version="1.0" encoding="UTF-8"?> <Context useHttpOnly="false" path="/bbc"> <Realm className="com.bbc.tomcat.BBCSecurityRealm"/> </Context> 

After adding this file, I get the following error when starting Tomcat "

 ERROR ecmdefault util.digester.Digester 18:37:14,477 localhost-startStop-1 : Parse Fatal Error at line 1 column 1: Content is not allowed in prolog. org.xml.sax.SAXParseException: Content is not allowed in prolog. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388) at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1427) 
+7
source share
2 answers

Your xml file has some invisible characters (most likely a specification) at the beginning (up to <?xml version="1.0" encoding="UTF-8"?> ) That are not allowed in xml. You can view it using the hex editor. The easiest way to fix this is to create an empty text file and copy the contents into it, change the extension to xml.

Mark the answer for more help.

From http://www.rgagnon.com/javadetails/java-handle-utf8-file-with-bom.html

The UTF8 file is a special case, because it is not recommended to add a specification to them, since it can destroy other tools, such as Java. In fact, Java assumes that UTF8 does not have a specification, so if a specification is present, it will not be discarded and will be treated as data.

+13
source

I had a similar problem, but this link provided a solution.

Quote from the article.

Any characters before the start of the XML content will raise the error above.

 org.xml.sax.SAXParseException: Content is not allowed in prolog error message. 
0
source

All Articles