Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6606241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:22:30+00:00 2026-05-25T19:22:30+00:00

Yes, I know that general forms of this question have been asked time and

  • 0

Yes, I know that general forms of this question have been asked time and time again. However, I couldn’t find anything that helped me solve my problem, so am posting this question which is specifically about my problem.

I am trying to figure out why I am getting a SAXParseException (Content is not allowed in prolog.) as the OpenSAML library is trying to parse some XML. The most useful hints I found pointed toward an errant BOM at the beginning of the file, but there’s nothing like that. I also wrote a quick-and-dirty C#.NET routine to read the whole file as an array of bytes, iterate over it and tell me if any of them were >=0x80 (it found none). The XML is marked as utf-8. I am hoping that someone can provide me with a bit of insight as to what might be going wrong.

The initial portion of the XML file, as a hex dump, is (note the use of 0A as a newline; removing the line feed character entirely has no apparent effect):

000000000  3C 3F 78 6D 6C 20 76 65-72 73 69 6F 6E 3D 22 31   |<?xml version="1|
000000010  2E 30 22 20 65 6E 63 6F-64 69 6E 67 3D 22 55 54   |.0" encoding="UT|
000000020  46 2D 38 22 3F 3E 0A 3C-6D 64 3A 45 6E 74 69 74   |F-8"?>.<md:Entit|
000000030  79 44 65 73 63 72 69 70-74 6F 72 20 78 6D 6C 6E   |yDescriptor xmln|
000000040  73 3A 6D 64 3D 22 75 72-6E 3A 6F 61 73 69 73 3A   |s:md="urn:oasis:|
000000050  6E 61 6D 65 73 3A 74 63-3A 53 41 4D 4C 3A 32 2E   |names:tc:SAML:2.|
000000060  30 3A 6D 65 74 61 64 61-74 61 22 20               |0:metadata"     |

The stack trace for the root cause exception is:

org.xml.sax.SAXParseException: Content is not allowed in prolog.
    org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
    org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
    org.apache.xerces.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(Unknown Source)
    org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    org.opensaml.xml.parse.BasicParserPool$DocumentBuilderProxy.parse(BasicParserPool.java:665)
    my.Unmarshaller.unmarshall(Unmarshaller.java:39)
    ... internal calls omitted for brevity ...
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

The code that tries to do the unmarshalling is (type names fully qualified here; hopefully I am not leaving out something important):

package my;

public class Unmarshaller {

    protected static org.opensaml.xml.parse.ParserPool parserPool;

    static {
        org.opensaml.xml.parse.BasicParserPool _parserPool;
        _parserPool = new org.opensaml.xml.parse.BasicParserPool();
        _parserPool.setNamespaceAware(true);
        Unmarshaller.parserPool = _parserPool;
    }

    public Unmarshaller() {
        try {
            org.opensaml.DefaultBootstrap.bootstrap();
        } catch (org.opensaml.xml.ConfigurationException e) {
            throw new java.lang.RuntimeException (e);
        }
    }

    public Object unmarshall(String xml)
    throws org.opensaml.xml.io.UnmarshallingException {
        assert xml != null;
        assert !xml.isEmpty();
        assert Unmarshaller.parserPool != null;

        org.w3c.dom.Document doc;

        try {
            doc =
                (parserPool.getBuilder())
                    .parse( // <<<====== line 39 in original source code is here
                        new org.xml.sax.InputSource(
                            new java.io.StringReader(xml)
                        )
                    );
        } catch (org.xml.sax.SAXException e) {
            throw new org.opensaml.xml.io.UnmarshallingException(e);
        } catch (java.io.IOException e) {
            throw new org.opensaml.xml.io.UnmarshallingException(e);
        } catch (org.opensaml.xml.parse.XMLParserException e) {
            throw new org.opensaml.xml.io.UnmarshallingException(e);
        }

        // ... remainder of function omitted for brevity ...
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:22:31+00:00Added an answer on May 25, 2026 at 7:22 pm

    I can’t see anything wrong with the XML fragment in the file dump. And I believe you when you say that the XML file validates.

    However, you have not presented water-tight evidence that the XML that the parser sees is valid. For instance:

    • You might be trying to parse a different file to the one that you have dumped. (These things have been known to happen …).

    • Alternatively, there might be something wrong with the way that you are getting the XML into that String that you then parse.

    Try dumping the first few lines of the String that provides the parser source stream.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Yes, I know, yet another question about mutable objects. See this for general background
Yes, I know that the FAQ pretends to answer this, but it doesn't really.
Yes, I know that in ASP.NET MVC you have to use ViewModels. But I'm
Yes I know that it shouldn't be abused and that C# is primariy used
Yes, I know that downcast using dynamic_cast can't compile if the Base is not
Is it possible to know that a HTTP request is from Ajax?If yes, how?
(Yes I know I can call Java code from Scala; but that is pointless;
Yes, I know, the archive bit is evil. That being said, is there support
Yes I know, this title isn't really helpfull but this is the exact problem.
I´m trying to code a tooltip (Yes I know, I have my reasons to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.