当前位置: 代码迷 >> J2EE >> !怒求各位大神!导入了对应的包,也生成了字节码文件,但还是ClassNotFoundException啊
  详细解决方案

!怒求各位大神!导入了对应的包,也生成了字节码文件,但还是ClassNotFoundException啊

热度:75   发布时间:2016-04-21 21:04:51.0
在线等!怒求各位大神!导入了对应的包,也生成了字节码文件,但还是ClassNotFoundException啊啊啊!!
在前端jsp表单将关键词keywords提交给servlet,然后在servlet里调用lia.meetlucene里的Indexer类和Searcher类的主方法报错:
java.lang.ClassNotFoundException: org.apache.lucene.index.IndexableField
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1713)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1558)
at servlet.absSearchServ.doPost(absSearchServ.java:63)

相关代码:
servlet:absSearchServ

import lia.meetlucene.*;

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletExceptionIOException {
// TODO Auto-generated method stub

String keyword = request.getParameter("keywords");
String dataPath = "L:\\My Documents\\Courses\\IR\\exp\\data_shakespeare";
String indexPath = "L:\\My Documents\\Courses\\IR\\exp\\index_shakespeare";

String[] toIndexer = { indexPath, dataPath };
String[] toSearcher = { indexPath, keyword };
try {
Indexer.main(toIndexer);//这里报错
Searcher.main(toSearcher);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}


Java Rsources

------解决方案--------------------
目测没问题啊
断点看下,程序进入Indexer了吗?
------解决方案--------------------
一眼望去一排的叹号。。。。虽然说一般情况下不影响使用
你不妨把鼠标移上去看看提示啥
------解决方案--------------------
首先确认确认一下jar包是否全部加载。
确认之后,对照下面的代码,找一下问题所在:
package com.xnch.lucenesearch.internet;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.miscellaneous.LimitTokenCountAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.LogByteSizeMergePolicy;
import org.apache.lucene.index.LogMergePolicy;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.queryparser.classic.MultiFieldQueryParser;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.Filter;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.highlight.Formatter;
import org.apache.lucene.search.highlight.Fragmenter;
import org.apache.lucene.search.highlight.Highlighter;
import org.apache.lucene.search.highlight.QueryScorer;
import org.apache.lucene.search.highlight.Scorer;
import org.apache.lucene.search.highlight.SimpleFragmenter;
import org.apache.lucene.search.highlight.SimpleHTMLFormatter;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.Version;
import org.wltea.analyzer.lucene.IKAnalyzer;

import com.xnch.lucenesearch.bean.CourseInfo;

public class RAM_FSTest {
 public final String COURSE_ID = "courseId";
 public final String COURSE_NAME = "courseName";
 public final String USERNAME = "userName";
 public final String COURSE_INTRODU = "course_introdu";
 public final String UPLOAD_DATE = "upload_date";
 Analyzer analyzer = new IKAnalyzer();
 IndexWriter writer = null;
 Directory RAMDirectory = null;
 Directory fsDirectory = null;
 public final static String indexPath = "F:\\javadata\\javawebpro\\lucene\\luceneIndex1";

 public static void main(String[] args) throws Exception {
  RAM_FSTest  rf = new RAM_FSTest();
  相关解决方案