javax.xml.bind.UnmarshalException: unexpected element (uri:“”, local:“Group”)

前端 未结 14 1175
终归单人心
终归单人心 2020-12-02 10:13
unexpected element (uri:\"\", local:\"Group\"). Expected elements are <{}group>

Meet an exception when unmarshalling from xml



        
14条回答
  •  佛祖请我去吃肉
    2020-12-02 10:58

    None of the solutions mentioned here worked for me, I was still getting:

    Exception in thread "main" javax.xml.bind.UnmarshalException: unexpected element (uri:"java:XXX.XX.XX.XXX", local:"XXXXX")

    After lot of research through other sites below code worked for me-

    FileInputStream fis = new FileInputStream("D:/group.xml");
    SOAPMessage message = factory.createMessage(new MimeHeaders(), fis);
    JAXBContext jc = JAXBContext.newInstance(Group.class);
    Unmarshaller u = jc.createUnmarshaller();
    JAXBElement r = u.unmarshal(message.getSOAPBody().extractContentAsDocument(), Group.class);
    Group group = r.getValue();
    

提交回复
热议问题