线程“AWT-EventQueue-0”中的异常java.lang.NoClassDefFoundError

我试图将 .docx 文件读入 JTextPane ,但它给出了一些例外 . 我正在使用POI库 . 我该怎么办?请帮帮我 . 这是我的代码:

file = new File(
    "C:\\Users\\Siddique Ansari\\Documents\\CV Parser\\Siddique_Resume.docx");
FileInputStream fis=new FileInputStream(file.getAbsolutePath());
XWPFDocument document=new XWPFDocument(fis);// line no 549
extractor = new XWPFWordExtractor(document);
String fileData = extractor.getText();
Document doc = jTextPane1.getDocument();      
System.out.println(fileData);
doc.insertString(doc.getLength(), fileData, null);

这是 Exception

Exception in thread "AWT-EventQueue-0"
    java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException
at cvparser.ExcelSheet.jButton3ActionPerformed(ExcelSheet.java:549)
at cvparser.ExcelSheet.access$400(ExcelSheet.java:39)
at cvparser.ExcelSheet$5.actionPerformed(ExcelSheet.java:219)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
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:6263)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6028)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2475)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
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)
Caused by: java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlException
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 28 more

回答(1)

2 years ago

除了apache-poi JAR文件之外,例如,

1869113  11-26-12 17:22   poi-3.9/poi-3.9-20121203.jar
   936648  11-26-12 17:22   poi-3.9/poi-ooxml-3.9-20121203.jar
  4802621  11-26-12 17:22   poi-3.9/poi-ooxml-schemas-3.9-20121203.jar

您还需要 classpathooxml-lib 的JAR文件:

313898  04-05-09 14:28   poi-3.9/ooxml-lib/dom4j-1.6.1.jar
    26514  02-23-11 12:31   poi-3.9/ooxml-lib/stax-api-1.0.1.jar
  2666695  04-05-09 14:29   poi-3.9/ooxml-lib/xmlbeans-2.3.0.jar