I'm trying to unmarshal xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <CreateSmth> ............ </CreateSmth> 

to the next class

 @XmlRootElement(name = "CreateSmth") public class CreateSmth extends BasicRQType implements Serializable { 

and get the error:

 javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"CreateSmth"). Expected elements are (none) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:740) at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:262) at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:257) at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:124) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(UnmarshallingContext.java:1148) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:573) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:555) at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:168) at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:258) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:229) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:157) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:214) at ___.XmlUtils.xml2object(XmlUtils.java:22) at ___.parseXml(CreateSmth.java:44) at ___.MyClass.method(MyClass.java:24) at ?.* Когда запускаем парсинг xml _______.xml(________.feature:6) 

what could be the problem? Perhaps in that class ( BasicRQType ) from which CreateSmth is inherited?

 (public class BasicRQType implements Serializable без @XmlRootElement) 
  • one
    Format the code and add the full text of the error to the question. It is absolutely incomprehensible to what the last line of the question text refers. - Sergey Gornostaev
  • It is not clear what happens on the code snippets in question. Add the serialization code to the question with a usage example. - Mikhail Grebenev
  • Sergey Gornostaev, I apologize, I have been here recently. About the last page clarified. Mikhail Grebenev, added. - user288694

0