Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Content not allowed in Prolog error while parsing an xml using Stax Parser  RSS feed

Ajay Kumar Gour
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks,

I am trying to unmarshal xml using JAXB with StAX parser. But its throwing below mentioned exception. I know that issue is because of BOM patterns and parser is not able to parse the xml file when XMLStreamReader is created with Reader object. Does anybody know how to fix this issue? I can write a small workaround to fix it by skipping these characters in the Reader. But i am not convinced that it is a proper solution. I thought many would have hit issue but to my surprise there's nothing available while googloing about it.

- with linked exception:
[ ParseError at [row,col]:[1,1]
Message: Content is not allowed in prolog.]
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(
at java.lang.reflect.Method.invoke(
at org.junit.internal.runners.TestMethod.invoke(
at org.junit.internal.runners.MethodRoadie.runTestMethod(
at org.junit.internal.runners.MethodRoadie$
at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(
at org.junit.internal.runners.MethodRoadie.runTest(
at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(
at org.junit.internal.runners.JUnit4ClassRunner.runMethods(
at org.junit.internal.runners.JUnit4ClassRunner$
at org.junit.internal.runners.ClassRoadie.runUnprotected(
at org.junit.internal.runners.ClassRoadie.runProtected(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
Caused by: ParseError at [row,col]:[1,1]
Message: Content is not allowed in prolog.
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(
... 26 more

Any help would be appreciated.

- Ajay
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!