简体   繁体   English

org.xml.sax.SAXParseException:带有jaxbUnmarshaller的文件过早结束

[英]org.xml.sax.SAXParseException: Premature end of file with jaxbUnmarshaller

This is a java method which unmarshalls xml file. 这是一个将XML文件解组的Java方法。

I looked for several problems with this error but I couldn't find an answer. 我寻找了与此错误有关的几个问题,但找不到答案。

    @WebMethod(operationName = "List_Flights")
    public List<FlightAvailableOffers> List_Flights() {//ArrayList<String[]>

       FlightAvailableOffers flighte = new FlightAvailableOffers();
        Flights flight = new Flights();
        List<FlightAvailableOffers> bookingAvailFlights = flight.getOffersBooking();
        try {

        File file = new File("Flight_Bookings.xml");

        JAXBContext jaxbContext = JAXBContext.newInstance(FlightAvailableOffers.class);
        Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
        flight = (Flights)jaxbUnmarshaller.unmarshal(file);
                //List<FlightAvailableOffers> bookingAvailFlights = flight.getOffersBooking();

            FlightAvailableOffers booking = new FlightAvailableOffers();

            Iterator itr = bookingAvailFlights.iterator();    
            while (itr.hasNext()) {
                booking = (FlightAvailableOffers) itr.next();
                bookingAvailFlights.add(booking);
            }

      } catch (JAXBException e) {
              System.out.println(e.getCause());
      }


        return bookingAvailFlights;

    }   
}

But when I run this it shows this message 但是当我运行它时会显示此消息

"org.xml.sax.SAXParseException: Premature end of file with jaxbUnmarshaller" “ org.xml.sax.SAXParseException:带有jaxbUnmarshaller的文件过早结束”

Can anyone help me to get rid of this? 谁能帮我摆脱这个困扰?

There is an error in flightinfo.xsd. flightinfo.xsd中存在错误。 The tns: namespace is declared in the document.. tns:名称空间在文档中声明。

Recorded reason: UndeclaredPrefix: Cannot resolve 'tns:FlightAvailableOffers' as a QName: the prefix 'tns' is not declared 记录的原因:UndeclaredPrefix:无法将'tns:FlightAvailableOffers'解析为QName:未声明前缀'tns'

Hint: 暗示:

You can validate your xml against xsd through online tools. 您可以通过在线工具针对xsd验证xml。

I would recommend the below one.. XML Validation against XML Schema Document 我会推荐以下一种。. 针对XML模式文档的XML验证

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 org.xml.sax.SAXParseException:*VALID* XML 的文件过早结束 - org.xml.sax.SAXParseException: Premature end of file for *VALID* XML org.xml.sax.SAXParseException:过早的结束文件 - org.xml.sax.SAXParseException: Premature end file 轴:faultString:org.xml.sax.SAXParseException:文件过早结束 - Axis: faultString: org.xml.sax.SAXParseException: Premature end of file org.xml.sax.SAXParseException:文件过早结束 - org.xml.sax.SAXParseException: Premature end of file org.xml.sax.SAXParseException:文件过早结束 - org.xml.sax.SAXParseException: Premature end of file 引起原因:org.xml.sax.SAXParseException:文件过早结束 - Caused by: org.xml.sax.SAXParseException: Premature end of file 文件过早结束。 org.xml.sax.SAXParseException; 文件过早结束。[致命错误]:-1:-1: - Premature end of file. org.xml.sax.SAXParseException; Premature end of file.[Fatal Error] :-1:-1: 解析RSS时出错-&gt; org.xml.sax.SAXParseException; lineNumber:1; columnNumber:1; 文件过早结束 - Error Parsing RSS -> org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature end of file org.xml.sax.SAXParseException; 尝试从请求中获取 xml 输入时文件过早结束 - org.xml.sax.SAXParseException; Premature end of file when trying to get an xml input from request Java JaxB Unmarshaller提供org.xml.sax.SAXParseException文件的过早结尾 - Java JaxB Unmarshaller giving org.xml.sax.SAXParseException Premature end of file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM