2012-07-12 59 views
2

我試圖創建一個xml文件。當我創建文件時,我獲得了此錯誤。 我真的不知道它是什麼。它是一個非常奇怪的錯誤。文件被正確創建,但沒有寫入其中。創建xml文件的異常

Exception in thread "AWT-EventQueue-0" java.lang.AbstractMethodError: gnu.xml.dom.DomDocument.getXmlStandalone()Z 
    at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.setDocumentInfo(DOM2TO.java:377) 
    at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:131) 
    at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:98) 
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:683) 
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:727) 
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:340) 
    at org.w3c.jigmonitor.controller.Controller.writePerformancesXmlFile(Controller.java:191) 
    at org.w3c.jigmonitor.controller.Controller.actionPerformed(Controller.java:68) 
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018) 
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341) 
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) 
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) 
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) 
    at java.awt.Component.processMouseEvent(Component.java:6505) 
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3321) 
    at java.awt.Component.processEvent(Component.java:6270) 
    at java.awt.Container.processEvent(Container.java:2229) 
    at java.awt.Component.dispatchEventImpl(Component.java:4861) 
    at java.awt.Container.dispatchEventImpl(Container.java:2287) 
    at java.awt.Component.dispatchEvent(Component.java:4687) 
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832) 
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492) 
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422) 
    at java.awt.Container.dispatchEventImpl(Container.java:2273) 
    at java.awt.Window.dispatchEventImpl(Window.java:2719) 
    at java.awt.Component.dispatchEvent(Component.java:4687) 
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:703) 
    at java.awt.EventQueue.access$000(EventQueue.java:102) 
    at java.awt.EventQueue$3.run(EventQueue.java:662) 
    at java.awt.EventQueue$3.run(EventQueue.java:660) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) 
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87) 
    at java.awt.EventQueue$4.run(EventQueue.java:676) 
    at java.awt.EventQueue$4.run(EventQueue.java:674) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) 
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:673) 
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244) 
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163) 
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151) 
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147) 
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139) 
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:97) 

這是我用它來創建XML文件的代碼:

DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); 
        DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); 

        Document doc = docBuilder.newDocument(); 
        Element rootElement = doc.createElement("performances"); 
        doc.appendChild(rootElement); 

        Attr attr = doc.createAttribute("date"); 
        attr.setValue(dateFormat.format(cal.getTime()).toString()); 
        rootElement.setAttributeNode(attr); 

        //Uptime 
        Element uptime = doc.createElement("uptime"); 
        rootElement.appendChild(uptime); 

        Element days = doc.createElement("days"); 
        days.appendChild(doc.createTextNode(new Long(duptime).toString())); 
        uptime.appendChild(days); 

        Element hours = doc.createElement("hours"); 
        hours.appendChild(doc.createTextNode(new Long(huptime).toString())); 
        uptime.appendChild(hours); 

        Element minutes = doc.createElement("minutes"); 
        minutes.appendChild(doc.createTextNode(new Long(muptime).toString())); 
        uptime.appendChild(minutes); 

        Element seconds = doc.createElement("seconds"); 
        seconds.appendChild(doc.createTextNode(new Long(suptime).toString())); 
        uptime.appendChild(seconds); 

        //TotalHitCount 
        Element totalhitcount = doc.createElement("totalhitcount"); 
        totalhitcount.appendChild(doc.createTextNode(new Long(stats.gettotal_hit_count()).toString())); 
        rootElement.appendChild(totalhitcount); 

        //EmittedBytes 
        Element emittedbytes = doc.createElement("emittedbytes"); 
        emittedbytes.appendChild(doc.createTextNode(new Long(stats.getemitted_bytes()).toString())); 
        rootElement.appendChild(emittedbytes); 

        //Avghitsec 
        Element avghitsec = doc.createElement("avghitsec"); 
        avghitsec.appendChild(doc.createTextNode(new Float(stats.getavg_hit_sec()).toString())); 
        rootElement.appendChild(avghitsec); 

        //Avgbyteshit 
        Element avgbyteshit = doc.createElement("avgbyteshit"); 
        avgbyteshit.appendChild(doc.createTextNode(new Long(stats.getavgbytes_hit()).toString())); 
        rootElement.appendChild(avgbyteshit); 

        //Avgbps 
        Element avgbps = doc.createElement("avgbps"); 
        avgbps.appendChild(doc.createTextNode(new Long(stats.getavgbps()).toString())); 
        rootElement.appendChild(avgbps); 

        //Total Threads 
        Element totalthreads = doc.createElement("totalthreads"); 
        totalthreads.appendChild(doc.createTextNode(new Long(stats.gettotal_threads()).toString())); 
        rootElement.appendChild(totalthreads); 

        //Idle Threads 
        Element idlethreads = doc.createElement("idlethreads"); 
        idlethreads.appendChild(doc.createTextNode(new Long(stats.getidle_threads()).toString())); 
        rootElement.appendChild(idlethreads); 

        TransformerFactory transformerFactory = TransformerFactory.newInstance(); 
        Transformer transfomer = transformerFactory.newTransformer(); 
        DOMSource source = new DOMSource(doc); 
        StreamResult result = new StreamResult(new File("/home/mazzy/Scrivania/perfor_"+dateFormat.format(cal.getTime()).toString()+".xml")); 

        transfomer.transform(source, result); 

我在主變差動method.any想法,例外是我得到這個錯誤?

回答

2

這是某種引起的,當你從那些在classpath中,當你運行它編譯你的代碼在classpath中有不同的JAR配置問題。

1

公共類AbstractMethodError 延伸IncompatibleClassChangeError

當應用程序試圖調用一個抽象方法拋出。通常,這個錯誤被編譯器捕獲;此錯誤只能在運行時發生,如果某些類的定義自上次編譯當前執行的方法以來發生了不兼容的更改。

聽起來像是你可能已經錯過了實現JAR