JAXB implementations will try to match on the root element of the document (not on a child element).
If you want to unmarshal to the middle of an XML document then you can parse the document with StAX advance the XMLStreamReader
to the desired element and then unmarshal that.
For More Information
UPDATE
now I am getting the following error. An Error: javax.xml.bind.UnmarshalException - with linked exception: [javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"Obj123"). Expected elements are (none)].
A JAXBContext
only knows about the classes you tell it about. Instead of:
JAXBContext jaxbContext = JAXBContext.newInstance();
You need to do:
JAXBContext jaxbContext = JAXBContext.newInstance(Obj123.class);