Lucene 为什么我会得到这个错误java.lang.ClassNotFoundException?

Lucene 为什么我会得到这个错误java.lang.ClassNotFoundException?,lucene,noclassdeffounderror,Lucene,Noclassdeffounderror,为什么我会收到这个错误消息 Testcase: createIndexBatch_usingTheTestArchive(src.LireHandlerTest): Caused an ERROR at/lux/imageanalysis/ColorLayoutImpl java.lang.NoClassDefFoundError: at/lux/imageanalysis/ColorLayoutImpl at net.semanticmetadata.lire.i

为什么我会收到这个错误消息

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索引。当我尝试使用文档生成器创建文档时,它会向我显示此错误消息

第一次运行输入参数: 文件路径:“测试存档”(这是一个图像存档) whereToStoreIndex:“test_index”(我将在其中存储索引) createNewIndex:true

由于该方法是递归的(请参阅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;
    }

听起来您缺少一个java库

我认为你需要下载哈里发和埃米尔,这可能是由里尔间接使用


谢谢!工作!我错过了一个名为caliph-emir-cbir.jar的jar库。我只有lucene和lire库。得到相同的错误,但不需要下载哪些文件,我尝试了很多次都没有成功。