为什么我在线程“AWT-EventQueue-2”java.lang.NoClassDefFoundError中得到Exception?

时间:2013-12-28 23:05:50

标签: java javabeans

我在网上找到一个java文件,允许我在网址中读取pdf并将其保存到我的本地计算机, 我已成功编译它并自定义为javabean所以我可以在我的应用程序中使用,但当我测试它时,我收到下一条错误消息。 我已经将这个库(PDFOne.jar文件)添加到netbean中的项目中,并且所有内容都可以很好地编译。

实际上,该程序检测到我的pdf网址并验证它是一个有效的pdf文件,但随后出现错误:

任何提示?我是java世界的全新人物。 提前谢谢

Exception in thread "AWT-EventQueue-2" java.lang.NoClassDefFoundError: com/gnostice/pdfone/PdfDocument
    at Read_PDF_From_URL.setProperty(Read_PDF_From_URL.java:51)
    at oracle.forms.handler.ComponentItem.setCustomProperty(Unknown Source)
    at oracle.forms.handler.ComponentItem.onUpdate(Unknown Source)
    at oracle.forms.handler.JavaContainer.onUpdate(Unknown Source)
    at oracle.forms.handler.UICommon.onUpdate(Unknown Source)
    at oracle.forms.engine.Runform.onUpdateHandler(Unknown Source)
    at oracle.forms.engine.Runform.processMessage(Unknown Source)
    at oracle.forms.engine.Runform.processSet(Unknown Source)
    at oracle.forms.engine.Runform.onMessageReal(Unknown Source)
    at oracle.forms.engine.Runform.onMessage(Unknown Source)
    at oracle.forms.engine.Runform.processEventEnd(Unknown Source)
    at oracle.ewt.lwAWT.LWComponent.redispatchEvent(Unknown Source)
    at oracle.ewt.lwAWT.LWComponent.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.gnostice.pdfone.PdfDocument
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 39 more

这是源代码的一部分:

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.ConnectException;
import java.net.URL;
import java.net.URLConnection;
import oracle.forms.properties.*;
import oracle.forms.ui.*;

import com.gnostice.pdfone.PdfDocument;
import java.net.MalformedURLException;

public class Read_PDF_From_URL   extends VTextArea {
    private static final ID GEN = ID.registerProperty("sav");

  public boolean setProperty(ID id, Object value) {
    boolean retorno = true;

    try {
       if (id == GEN) {
           System.out.println("if");         
         URL url1 =
      new URL("http://www.gnostice.com/downloads/Gnostice_PathQuest.pdf");

      byte[] ba1 = new byte[1024];
      int baLength;
      FileOutputStream fos1 = new FileOutputStream("sibdownload.pdf");

      // Contacting the URL
      System.out.print("Connecting to " + url1.toString() + " ... ");
      URLConnection urlConn = url1.openConnection();

      // Checking whether the URL contains a PDF
      if (!urlConn.getContentType().equalsIgnoreCase("application/pdf")) {
          System.out.println("FAILED.\n[Sorry. This is not a PDF.]");
      } else {
        try {

          // Read the PDF from the URL and save to a local file
          InputStream is1 = url1.openStream();
          while ((baLength = is1.read(ba1)) != -1) {
              fos1.write(ba1, 0, baLength);
          }
          fos1.flush();
          fos1.close();
          is1.close();

          // Load the PDF document and display its page count
          System.out.print("DONE.\nProcessing the PDF ... ");
          PdfDocument doc = new PdfDocument();
          try {
            doc.load("sibdownload.pdf");
            System.out.println("DONE.\nNumber of pages in the PDF is " +

1 个答案:

答案 0 :(得分:1)

我已经解决了我的问题......第一件事是我需要在我的类路径中包含jar文件,以及我需要签署jar文件的第二件事。