unexpected element (uri:"", local:"Group"). Expected elements are <{}group>
Meet an exception when unmarshalling from xml
JAXBContext jc = JAXBContext.newInstance(Group.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
Group group = (User)unmarshaller.unmarshal(new File("group.xml"));
Group class has no any annotation and group.xml just contains data.
Anything can be the cause?
I had the same issue. I added following attributes to
<xs:schema..>
elementFormDefault="qualified" attributeFormDefault="unqualified"and re-generated java classes by running xjc, which corrected package-info.java.
This fixed the issue for me.
If none of the above works, try adding
@XmlRootElement(name="Group")
to the Group classs.Same to me. The name of the mapping class was
Mbean
but the tag root name wasmbean
so I had to add the annotation: