2011-02-24 105 views
0

爲什麼我得到這個錯誤信息?爲什麼我得到這個錯誤java.lang.ClassNotFoundException?

Testcase: createIndexBatch_usingTheTestArchive(src.LireHandlerTest):  Caused an ERROR 
at/lux/imageanalysis/ColorLayoutImpl 
java.lang.NoClassDefFoundError: at/lux/imageanalysis/ColorLayoutImpl 
     at net.semanticmetadata.lire.impl.SimpleDocumentBuilder.createDocument(Unknown Source) 
     at net.semanticmetadata.lire.AbstractDocumentBuilder.createDocument(Unknown Source) 
     at backend.storage.LireHandler.createIndexBatch(LireHandler.java:49) 
     at backend.storage.LireHandler.createIndexBatch(LireHandler.java:57) 
     at src.LireHandlerTest.createIndexBatch_usingTheTestArchive(LireHandlerTest.java:56) 
Caused by: java.lang.ClassNotFoundException: at.lux.imageanalysis.ColorLayoutImpl 
     at java.net.URLClassLoader$1.run(URLClassLoader.java:202) 
     at java.security.AccessController.doPrivileged(Native Method) 
     at java.net.URLClassLoader.findClass(URLClassLoader.java:190) 
     at java.lang.ClassLoader.loadClass(ClassLoader.java:307) 
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) 
     at java.lang.ClassLoader.loadClass(ClassLoader.java:248) 

我想創建一個使用Lire創建的文檔的Lucene索引。當我開始嘗試使用文檔生成器創建文檔時,它會給我提供此錯誤消息。

輸入PARAMATERS首輪: 文件路徑: 「test_archive」(這是一個圖像檔案) whereToStoreIndex 「的test_index」(我要去的地方來存儲索引) createNewIndex:真

由於該方法遞歸(請參閱if語句,檢查它是否爲目錄),它會自動調用多次,但所有遞歸調用都使用createNewIndex = false。

下面是代碼:

public static boolean createIndexBatch(String filepath, String whereToStoreIndex, boolean createNewIndex){ 
     DocumentBuilder docBldr = DocumentBuilderFactory.getDefaultDocumentBuilder(); 
     try{ 
      IndexWriter indexWriter = new IndexWriter(
                FSDirectory.open(new File(whereToStoreIndex)), 
                new SimpleAnalyzer(), 
                createNewIndex, 
                IndexWriter.MaxFieldLength.UNLIMITED 
                ); 
      File[] files = FileHandler.getFilesFromDirectory(filepath); 
      for(File f:files){ 
       if(f.isFile()){ 
        //Hopper over Thumbs.db filene... 
        if(!f.getName().equals("Thumbs.db")){ 
         //Creating the document that is going to be stored in the index 
         String name = f.getName(); 
         String path = f.getPath(); 
         FileInputStream stream = new FileInputStream(f); 
         Document doc = docBldr.createDocument(stream, f.getName()); 

         //Add document to the index 
         indexWriter.addDocument(doc); 
        } 
       }else if(f.isDirectory()){ 
        indexWriter.optimize(); 
        indexWriter.close(); 
        LireHandler.createIndexBatch(f.getPath(), whereToStoreIndex, false); 
       } 
      } 
      indexWriter.close(); 
     }catch(IOException e){ 
      System.out.print("IOException in createIndexBatch:\n"+e.getMessage()+"\n"); 
      return false; 
     } 

     return true; 
    } 

回答

0

這聽起來像你缺少一個Java庫。

我想你需要下載Caliph &埃米爾,這可能是由里爾間接使用。

http://www.semanticmetadata.net/download/

+0

謝謝!成功了!我錯過了一個名爲caliph-emir-cbir.jar的jar庫。我只有lucene和里爾圖書館。 – 2011-02-24 16:40:11

+0

獲取同樣的錯誤,但不要哪些文件需要下載,我嘗試了很多沒有得到成功。 – 2014-12-02 10:42:12