1
Может ли кто-нибудь помочь мне разобраться в первопричине этой проблемы.JAXB: .UnmarshalException - со связанным исключением: [javax.xml.stream.XMLStreamException
XML:
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xml:base="https://*******/odata/**/">
Код:
jaxbContext = JAXBContext.newInstance(Entry.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
XMLInputFactory xif = XMLInputFactory.newFactory();
xif.setProperty(XMLInputFactory.SUPPORT_DTD, false);
XMLStreamReader xsr = xif.createXMLStreamReader(new StreamSource(metaData));
Entry entry = (Entry) jaxbUnmarshaller.unmarshal(xsr);
Класс:
@XmlRootElement(name = "entry")
@XmlAccessorType(XmlAccessType.FIELD)
public class Entry {
Ex ception:
javax.xml.bind.UnmarshalException
- with linked exception:
[javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
Message: Content is not allowed in prolog.]
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Unknown Source)
Убедитесь, что XML не имеет [спецификацию в начале] (HTTP://stackoverflow.com/questions/2599919/java-parsing-xml-document-gives-content-not-allowed-in-prolog-error). В вашем XML также отсутствует закрывающий корневой тег. – approxiblue
проверял файл xml и никаких нежелательных символов. @approxiblue – thanga