Hello everyone!
when i using StAX and JAXB unmarshalling BPEL(also an XML) file, i receive
following error:
Exception in thread "main" java.lang.IllegalStateException: reader must be
on a START_ELEMENT event, not a 4 event
i am sure my XML instance document is valid.
i get one of the event then umarshal it. Here is my java code:
public void Parse() throws
XMLStreamException,FileNotFoundException,JAXBException {
JAXBContext jaxbContext = JAXBContext
.newInstance("cn.edu.xidian.sei.balas.crocodile.bpelclasses");
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
XMLEventReader eventReader = inputFactory
.createXMLEventReader(new FileReader(theBPELFile));
while (eventReader.hasNext()) {
XMLEvent event = eventReader.nextEvent();
if (event.isStartElement()) {
StartElement start = event.asStartElement();
if(start.getName().getLocalPart().equalsIgnoreCase("invoke")){
TInvoke theInvoke = (TInvoke)unmarshaller.unmarshal(eventReader);
}
}
}
}
But why this error happened? the google seems cannot give me the answer.
Thank 4 any suggestion....
--
-------------------------------------------
Kimia Zhu
http://blog.fedorachina.cn