小弟初开始学习java的lunece做全文索引
在 public synchronized static void runJob()  throws Exception{
        Map envList = new HashMap();
        IEnv env = null;
        try {
            while (jobList.size() > 0) {
                IJob job = ( (IJob) jobList.get(0));
                env = (IEnv) envList.get(job.getClass());
                if (env == null) {
                    env = EnvFactory.createEnv(job);
                    envList.put(job.getClass(), env);
                    env.initEnv();
                }
                job.run(env);
                //
                jobList.remove(job);
            }
        }
        catch (Exception ex) {
            throw ex;
        }finally{
            Iterator it = envList.values().iterator();
            while (it.hasNext()) {
                ( (IEnv) it.next()).release();
            }
        }
    }调用,
public void release() {
     System.out.println("pp path="+path);
        try {
            try {
                writer.optimize();
            }
            catch (CorruptIndexException ex2) {
            }
            catch (IOException ex2) {
            }
            writer.close();
//            System.out.println("index over");
        }
        catch (CorruptIndexException ex) {
        }
        catch (IOException ex) {
        }
        try {
            LuceneUtils.SearcherReload(path);
        }
        catch (Exception ex1) {
        }
    }
当然writer在前面有初始化
IndexWriter writer = null;
private static Analyzer analyzer = new IK_CAnalyzer();
String path =  null;
public PowerProcessIndexEnv() {
         path  = getClass().getClassLoader().getResource("").
                getFile() + "../lucene_index/pp";    }    public PowerProcessIndexEnv(IJob job) {
        this.create =((IndexPowerProcessJob) job).isNewCreate();
        path = getClass().getClassLoader().getResource("").
            getFile() + "../lucene_index/pp";
    }
public void initEnv() throws Exception {
        //初始化IndexWriter
        try {
            writer = new IndexWriter(path, analyzer, this.create);
        }
        catch (java.io.FileNotFoundException ex) {
            writer = new IndexWriter(path, analyzer, true);
        }
        writer.setMergeFactor(1000);
        writer.setUseCompoundFile(false);
        this.put("writer",writer);
//
    }
开始如果在路径里面没有索引文件的时候,执行是不报错的。但如果有了索引文件以后,再次执行就报
java.lang.NullPointerException
at com.beyondbit.lucene.index.support.env.PowerProcessIndexEnv.release(PowerProcessIndexEnv.java:90)
at com.beyondbit.lucene.index.LuceneControl.runJob(LuceneControl.java:105)
at com.beyondbit.lucene.index.LuceneControl$1.run(LuceneControl.java:68)
at java.lang.Thread.run(Thread.java:534)
ERROR 03-19 16:11:37 [Thread-37] (LuceneControl.java:72) - java.lang.NullPointerException
哪位高手能指点下迷津????
在线等。。