【问题标题】:Why am i getting this error java.lang.ClassNotFoundException?为什么我收到此错误 java.lang.ClassNotFoundException?
【发布时间】:2011-02-24 12:11:27
【问题描述】:

为什么我会收到此错误消息?

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 索引。当我尝试使用文档生成器创建文档时,它给了我这个错误消息。

输入参数首次运行: 文件路径:“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;
    }

【问题讨论】:

    标签: lucene noclassdeffounderror


    【解决方案1】:

    听起来您缺少一个 java 库。

    我认为您需要下载哈里发和埃米尔,这可能会被 Lire 间接使用。

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

    【讨论】:

    • 谢谢!工作!我错过了一个名为 caliph-emir-cbir.jar 的 jar 库。我只有 lucene 和 lire 库。
    • 得到同样的错误,但不知道需要下载哪些文件,我尝试了很多都没有成功。
    猜你喜欢
    • 1970-01-01
    • 2018-05-13
    • 2018-06-22
    • 2016-01-01
    • 2012-04-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多