2

I am using glassfish server and the following error keeps coming:

Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.
        at com.sun.enterprise.deployment.io.DeploymentDescriptorFile.read(DeploymentDescriptorFile.java:304)
        at com.sun.enterprise.deployment.io.DeploymentDescriptorFile.read(DeploymentDescriptorFile.java:226)
        at com.sun.enterprise.deployment.archivist.Archivist.readStandardDeploymentDescriptor(Archivist.java:480)
        at com.sun.enterprise.deployment.archivist.Archivist.readDeploymentDescriptors(Archivist.java:305)
        at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:213)
        at com.sun.enterprise.deployment.archivist.ApplicationArchivist.openArchive(ApplicationArchivist.java:813)
        at com.sun.enterprise.instance.WebModulesManager.getDescriptor(WebModulesManager.java:395)
        ... 65 more
SomeKittens
  • 38,868
  • 19
  • 114
  • 143
dawit
  • 29
  • 1
  • 1
  • 2
  • 2
    Please provide the ` – McDowell Sep 08 '10 at 07:48
  • possible duplicate of [org.xml.sax.SAXParseException: Content is not allowed in prolog](http://stackoverflow.com/questions/5138696/org-xml-sax-saxparseexception-content-is-not-allowed-in-prolog) – Raedwald Jul 18 '14 at 09:40

1 Answers1

4

Check this link

http://mark.koli.ch/2009/02/resolving-orgxmlsaxsaxparseexception-content-is-not-allowed-in-prolog.html

In short, some XML file contains the three-byte pattern (0xEF 0xBB 0xBF) at the front (right before <?xml ...?>), which is the UTF-8 byte order mark. The java's default XML parser can't handle this case.

The quick and dirty solution is to remove the white space at the front of the XML file:

String xml = "<?xml ...";
xml = xml.replaceFirst("^([\\W]+)<","<");

note that the String.trim() dost not enough, since it only trim the limited whitespace characters.

Starfish
  • 67
  • 4