16

I'm having trouble opening my main in my eclipse project. It keeps coming up with:

"content is not allowed in prolog"

I haven't altered my code or anything. I have no idea what has gone wrong, anybody seen this before?

Ranger
  • 653
  • 3
  • 7
  • 11
  • See also http://stackoverflow.com/questions/5138696/org-xml-sax-saxparseexception-content-is-not-allowed-in-prolog – Raedwald Jul 18 '14 at 09:21
  • I resolved a similar issue. See http://stackoverflow.com/a/32790768/922348. – rimsky Sep 25 '15 at 21:30
  • I don't want to publish such obvious answer separately, so I post it here: I had the same error (also with no changes to xslt). I just removed whole server from Eclipse and added new, clean one - it helped... – Krzysiek Oct 05 '15 at 14:14

14 Answers14

19

I had the same error and figured it out.

When I tried to create a new string resource, I tried to paste the new resource value on the "Android Resources" screen. To my surprise, the paste operation (using CTRL + V) does not work on that screen, and I tried it several times.

After that I started getting the error. When I switched from the "Android Resources" screen to the raw XML screen of the Strings.xml file, I noticed that all the text that I tried to paste was at the beginning of the file, like this:

Image content description. Image content description.<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">My App</string>
</resources>

And that was causing the error for me.

apaul
  • 16,092
  • 8
  • 47
  • 82
Aquanauta
  • 221
  • 2
  • 5
  • Same paste error here too (xml file). At first the error message looks like there is some part of code using the Prolog language... Should be invalid doctype or something like that, at least it stated the error was at line 1 :) – Christophe Roussy May 21 '13 at 09:58
  • This happened to me. You just saved me some frustration. Thank you sir. – Chris Feb 05 '14 at 11:46
  • @Aquanauta... I think I love you! you saved my life! +3 – user3241507 May 20 '14 at 19:36
4

Restarting Eclipse and Cleaning the problem dint help. I opened the .xml file in a XML editor and did a Validate on that error alone. this solved my problem. Hope this helps for people who still got the problem

Sergey K.
  • 24,894
  • 13
  • 106
  • 174
4

This error is generated during parsing of an XML document. Here is one writeup:

http://www.mkyong.com/java/sax-error-content-is-not-allowed-in-prolog/

You didn't provide sufficient information in your question to know which file might be corrupted, but search for xml files in your project and see if they look ok.

Konstantin Komissarchik
  • 28,879
  • 6
  • 61
  • 61
  • Looked through it all last night didn't find anything wrong. Started Eclipse this morning and it was fine, must be some sort of bug. – Ranger Mar 27 '11 at 09:20
  • 1
    don't know if this is a "solution", but I had the same error. I was able to access the Eclipse menu, selected Project -> Clean and selected all the projects. Closed the eclipse (first time hanged, second time successfully) and the opened again successfully. I think the java updated yesterday, not sure if this had something to do with the error. – Alex Angelico Mar 29 '11 at 23:33
2

Its most likely an encoding problem: (edit in notepad++ and select) encoding utf-8 -BOM

Jwalant Bhatt
  • 361
  • 2
  • 7
1

I had the same problem, It may be because of XML parser issue, I restarted the eclipse it started working fine.

0

I also had the same error.Check your Xml files.There may be syntax error in xml files.

anjaneya
  • 708
  • 9
  • 11
0

Having incorrect encoding information might cause this.

<?xml version="1.0" encoding="utf-16"?>

at the top of an ascii or utf-8 encoded file for example.

Greg Domjan
  • 13,943
  • 6
  • 43
  • 59
0

Yeah, I had the same, and the first line in strings.xml:

<?xml version="1.0" encoding="utf-8"?>

was marked with this error. Though I also didn't alter any code, yesterday, when I closed Eclipse, everything was fine, no errors (though some warnings were present, but that doesn't matter, I think)

All I did now is Selecting this line, Ctrl+X (Cut) it, Ctrl+S to save, Ctrl+V (Paste) it back and Ctrl+S again, and the error is gone. Not sure if it will work for everybody, but it did for me 8)

Highstaker
  • 1,015
  • 2
  • 12
  • 28
0

Check: that you have no any additional wrong text before in the beginning of file.

Egor Volk
  • 71
  • 1
  • 4
0

In my case I was seeing those error in java classes i.e. NOT XML and, the problem was related to a hidden file called .springBeans in the main project directory. I had a section "configs" and "autoconfigs" like:

java:org.DDDDDDDDDD.config.PersistenceConfig

java:org.DDDDDDDDDD.core.Application

When i moved everything to autoconfigs it all worked for me

Tito
  • 2,234
  • 6
  • 31
  • 65
0

In my case, server.xml got corrupted.

Go to pivotal/tomcat server location.

Path : base-instance\conf File Name: server.xml

So i tried replacing below content in that file and it worked fine.

Sample content:-

<?xml version="1.0" encoding="UTF-8"?>
<Server port="${base.shutdown.port}" shutdown="SHUTDOWN">
    <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
    <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
    <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>
    <Listener className="com.springsource.tcserver.serviceability.deploy.TcContainerDeployer"/>
    <Listener accessFile="${catalina.base}/conf/jmxremote.access" address="127.0.0.1" authenticate="true" className="com.springsource.tcserver.serviceability.rmi.JmxSocketListener" passwordFile="${catalina.base}/conf/jmxremote.password" port="${base.jmx.port}" useSSL="false"/>
    <GlobalNamingResources>
        <Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
    </GlobalNamingResources>
    <Service name="Catalina">
        <Executor maxThreads="300" minSpareThreads="50" name="tomcatThreadPool" namePrefix="tomcat-http--"/>
        <Engine defaultHost="localhost" name="Catalina">
            <Realm className="org.apache.catalina.realm.LockOutRealm">
                <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
            </Realm>
            <Host appBase="webapps" autoDeploy="true" deployOnStartup="true" deployXML="true" name="localhost" unpackWARs="true">
                <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="localhost_access_log." suffix=".txt"/>
            </Host>
        </Engine>
        <Connector acceptCount="100" connectionTimeout="20000" executor="tomcatThreadPool" maxKeepAliveRequests="15" port="${nio.http.port}" protocol="org.apache.coyote.http11.Http11NioProtocol" redirectPort="${nio.https.port}"/>
    </Service>
</Server>
Sireesh Yarlagadda
  • 12,978
  • 3
  • 74
  • 76
0

I had a similar issue and wanted to make a note, in case other had the same root cause that I did.

My issue was related to the xsi:schemaLocation. The url stated was no longer being served. Via googling, I got a copy of the actual xsd file, which I included locally then updated the reference. This solved my issue.

e.g. http://dozer.sourceforge.net/schema/beanmapping.xsd became beanmapping.xsd in the snippet below, after adding the .xsd file to the same folder.

<?xml version="1.0" encoding="UTF-8"?>
<mappings xmlns="http://dozer.sourceforge.net" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://dozer.sourceforge.net beanmapping.xsd">
James Oravec
  • 19,579
  • 27
  • 94
  • 160
0

i delete the c:/users/your_computer/appdata/.gradle/cache and it went go to normal

reza rahmad
  • 1,009
  • 10
  • 16
-1

I fix it with a non - xml file by clearing the file in the text editor, save the empty file and paste it back. (CTRL+A, CTRL+X, CTRL+S, CTRL+V, CTRL+S)

Sven Jörns
  • 31
  • 1
  • 5