当前位置: 首页 > 知识库问答 >
问题:

UnMarshalException:意外元素(URI:“”,本地:“SystemUnit”)

凌征
2023-03-14

UnMarshalException:意外元素(URI:“”,本地:“SystemUnit”)。需要的元素为<{http://xyz.abc.com/consumer/systems}SystemUnit>

 SystemUnit systemUnit;
 {
     final ByteArrayOutputStream originalStream = new ByteArrayOutputStream();
     try {
         final TeeInputStream tee = new TeeInputStream(new FileInputStream("E:/ws/test.xml"), originalStream);

         try {
             final JAXBContext jc = JAXBContext.newInstance(SystemUnit.class);
             final Unmarshaller unmarshaller = jc.createUnmarshaller();

             systemUnit = (SystemUnit)unmarshaller.unmarshal(tee);

           System.out.println("Success"); // Pending NO exceptions during processing...

         }
         catch (final javax.xml.bind.JAXBException e) {
             System.out.println("Exception came");
             e.printStackTrace();
         }
         finally {
             tee.close();
         }

    //     contactLog.setMessage(originalStream.toByteArray());
     }
     finally {
         originalStream.close();
     }

共有1个答案

阎麒
2023-03-14
<systemUnit xmlns="http://xyz.abc.com/consumer/systems">
 类似资料: