3
我在OpenBravoPOS v2.30
的工作,任何人都知道嗎?這是一個有免費許可證的POS機。 我試圖改進它,但在我的一臺測試計算機中,它失敗了。最重要的是,我讀了關於類似的情況在stackoverflow,但他們是無奈的。爲什麼我得到這個,org.xml.sax.SAXParseException,異常?
下面是完整的異常輸出:
WARNING: Analysis error. Invalid XML file.
org.xml.sax.SAXParseException: Premature end of file.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1427)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:1056)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at com.openbravo.pos.sales.JTicketLines.<init>(JTicketLines.java:70)
at com.openbravo.pos.sales.JTicketLinesMRB.<init>(JTicketLinesMRB.java:22)
at com.openbravo.pos.sales.JRefundLinesMRB.loadTicketLines(JRefundLinesMRB.java:97)
at com.openbravo.pos.sales.JRefundLines.<init>(JRefundLines.java:42)
at com.openbravo.pos.sales.JRefundLinesMRB.<init>(JRefundLinesMRB.java:44)
at com.openbravo.pos.sales.JTicketCatalogLinesMRB.newRefundLines(JTicketCatalogLinesMRB.java:23)
at com.openbravo.pos.sales.JTicketCatalogLines.<init>(JTicketCatalogLines.java:48)
at com.openbravo.pos.sales.JTicketCatalogLinesMRB.<init>(JTicketCatalogLinesMRB.java:17)
at com.openbravo.pos.sales.JPanelTicketEditsMRB.getSouthComponent(JPanelTicketEditsMRB.java:52)
at com.openbravo.pos.sales.JPanelTicket.init(JPanelTicket.java:272)
at com.openbravo.pos.sales.JPanelTicketEditsMRB.init(JPanelTicketEditsMRB.java:77)
at com.openbravo.pos.forms.JRootApp.getBean(JRootApp.java:409)
at com.openbravo.pos.forms.JPrincipalApp.showTask(JPrincipalApp.java:378)
at com.openbravo.pos.forms.MenuPanelAction.actionPerformed(MenuPanelAction.java:46)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at org.jdesktop.swingx.JXHyperlink.fireActionPerformed(JXHyperlink.java:244)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6290)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6055)
at java.awt.Container.processEvent(Container.java:2039)
at java.awt.Component.dispatchEventImpl(Component.java:4653)
at java.awt.Container.dispatchEventImpl(Container.java:2097)
at java.awt.Component.dispatchEvent(Component.java:4481)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4575)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4236)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4166)
at java.awt.Container.dispatchEventImpl(Container.java:2083)
at java.awt.Window.dispatchEventImpl(Window.java:2482)
at java.awt.Component.dispatchEvent(Component.java:4481)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:648)
at java.awt.EventQueue.access$000(EventQueue.java:84)
at java.awt.EventQueue$1.run(EventQueue.java:607)
at java.awt.EventQueue$1.run(EventQueue.java:605)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
at java.awt.EventQueue$2.run(EventQueue.java:621)
at java.awt.EventQueue$2.run(EventQueue.java:619)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:618)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
它指出在該行的代碼:
private static SAXParser m_sp = null;
public JTicketLines(String ticketline) {
initComponents();
ColumnTicket[] acolumns = new ColumnTicket[0];
if (ticketline != null) {
try {
if (m_sp == null) {
SAXParserFactory spf = SAXParserFactory.newInstance();
m_sp = spf.newSAXParser();
}
ColumnsHandler columnshandler = new ColumnsHandler();
m_sp.parse(new InputSource(new StringReader(ticketline)), columnshandler);
acolumns = columnshandler.getColumns();
} catch (ParserConfigurationException ePC) {
logger.log(Level.WARNING, LocalRes.getIntString("exception.parserconfig"), ePC);
} catch (SAXException eSAX) {
logger.log(Level.WARNING, LocalRes.getIntString("exception.xmlfile"), eSAX);
} catch (IOException eIO) {
logger.log(Level.WARNING, LocalRes.getIntString("exception.iofile"), eIO);
}
}
initColumns(acolumns);
}
爲什麼它拋出我的異常?這是XML文件的問題?它應該是在不同計算機上的相同XML。
LoadTicketLines:
protected void loadTicketLines(DataLogicSystem dlSystem) {
ticketlines = new JTicketLines(dlSystem.getResourceAsXML("Ticket.Line"));
}
和XML文件:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Openbravo POS is a point of sales application designed for touch screens.
Copyright (C) 2007-2009 Openbravo, S.L.
http://sourceforge.net/projects/openbravopos
This file is part of Openbravo POS.
Openbravo POS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Openbravo POS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Openbravo POS. If not, see <http://www.gnu.org/licenses/>.
-->
<line>
<!-- <column name="label.item" width="125" align="left" value="<html>#if ($ticketline.isProductCom()) <i>*&nbsp;&nbsp;${ticketline.printNameAndDiscount()}</i> #else ${ticketline.printNameAndDiscount()} #end<br>${ticketline.getProductAttSetInstDesc()}"/> -->
<column name="label.item" fontsize="16" width="125" align="left" value="${ticketline.printName()}"/>
<column name="label.units" fontsize="16" width="50" align="right" value="x${ticketline.printMultiply()}"/>
<!-- PARTY -->
<column name="label.pvp" fontsize="16" width="50" align="right" value="${ticketline.printPVP()}"/>
<column name="label.discount" fontsize="16" width="50" align="right" value="${ticketline.printDicountPercent()}"/>
<column name="label.TotalLine" fontsize="16" width="80" align="right" value="${ticketline.printValue()}"/>
</line>
很抱歉,如果它包含了大量的代碼,不知道該如何解釋更好
什麼是'ticketline'? stacktrace告訴你它遇到了「文件過早結束」,所以我會看看XML,因爲它可能不是格式良好的。 – andyb 2013-05-09 08:02:46
由於聲明爲靜態,可能會導致SAXParser問題?這是什麼代碼? – Kuchi 2013-05-09 08:04:02
我會修改我的問題以顯示XML – DavidM 2013-05-09 08:04:08