lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Busch (JIRA)" <j...@apache.org>
Subject [jira] Closed: (LUCENE-647) Error when tried to index with IndexWriter on Luncene 2.0
Date Sun, 27 May 2007 04:48:16 GMT

     [ https://issues.apache.org/jira/browse/LUCENE-647?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Michael Busch closed LUCENE-647.
--------------------------------

    Resolution: Duplicate

This is a dup of LUCENE-643.

> Error when tried to index with IndexWriter on Luncene 2.0
> ---------------------------------------------------------
>
>                 Key: LUCENE-647
>                 URL: https://issues.apache.org/jira/browse/LUCENE-647
>             Project: Lucene - Java
>          Issue Type: Bug
>    Affects Versions: 2.0.0
>         Environment: Windows 2000/ Jdk 1.4 
>            Reporter: sherin george
>
> Dear Sir, 
> I am getting the following runtime exception when I tried to integrate Lucene 2.0 with
my java application. 
> 500 Internal Server Error
> java.lang.ExceptionInInitializerError: java.lang.NullPointerException
> at org.apache.lucene.analysis.standard.StandardAnalyzer.tokenStream(StandardAnalyzer.java:72)
> at org.apache.lucene.index.DocumentWriter.invertDocument(DocumentWriter.java:162)
> at org.apache.lucene.index.DocumentWriter.addDocument(DocumentWriter.java:93)
> at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:476)
> at com.kms.utils.IndexFiles.addToIndex(IndexFiles.java:84)
> at com.kms.document.action.DocumentUploadSubmitAction.execute(DocumentUploadSubmitAction.java:180)
> at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
> at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
> at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
> at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
> at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)
> at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:604)
> at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
> at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
> at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
> at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
> at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
> at java.lang.Thread.run(Thread.java:536)
> Caused by: java.lang.NullPointerException
> at org.apache.lucene.analysis.standard.StandardFilter.<clinit>(StandardFilter.java:32)
>  ... 21 more
> I have identified that the exception occurs at execution of the following line of code
which indexes a document. 
> package com.kms.utils;
> import com.kms.parser.Parser;
> import com.kms.parser.ParserFactory;
> import com.kms.reuse.Constants;
> import org.apache.lucene.search.Hits;
> import org.apache.lucene.search.Query;
> import org.apache.lucene.queryParser.QueryParser;
> import org.apache.lucene.analysis.standard.StandardAnalyzer;
> import org.apache.lucene.document.Document;
> import org.apache.lucene.document.Field;
> import org.apache.lucene.index.IndexWriter;
> import org.apache.lucene.store.FSDirectory;
> import org.apache.lucene.search.IndexSearcher;
> import org.apache.lucene.analysis.Analyzer;
> import org.apache.lucene.store.Directory;
> import org.apache.lucene.demo.FileDocument;
> import java.io.*;
> public class IndexFiles
> {
>   public static void addToIndex(String fileName) 
>   {
>    try
>    {
>  Analyzer analyzer = new StandardAnalyzer();
> String filePath="D:\docs"; //Folder to files are save
>     String filePathName=filePath+"/"+fileName;
>     Directory directory = FSDirectory.getDirectory("D: \index",true); "; 
> //Folder to which index files are saved
>  Document doc = new Document();
>  File file = new File(filePathName);
>  Parser parser = ParserFactory.getParser(file);
>  StringBuffer content = null;
>  String name = "";
>  String author = "";
> String sourceDate = "";
>   String keywords = "";
> if (parser != null) 
>   {
>    content = parser.getContent();
>    name = parser.getTitle();
>    author = parser.getAuthor();
>    sourceDate = parser.getSourceDate();
>    keywords = parser.getKeywords();
>    }
>    doc.add(new Field("path",filePathName, Field.Store.YES,Field.Index.TOKENIZED));
>     doc.add(new Field("name",fileName,Field.Store.YES,Field.Index.TOKENIZED));
>    doc.add(new Field("contents",content.toString(),Field.Store.YES,Field.Index.TOKENIZED));
>    boolean flag=true;
>    File indexFiles=new File("D: \index");
>    String[] fileList=indexFiles.list();
>        if(fileList.length>1)
>  {
> flag=false;
> }
> else
> {
>  flag=true;
>  }
> IndexWriter iwriter = new IndexWriter(directory,analyzer,flag);
>  iwriter.setMaxFieldLength(25000);
> iwriter.addDocument(doc,analyzer);
>  iwriter.close();
> }
> catch(Exception e)
> {
> System.out.println(e);
> }
> }
> }
> I have checked all objects like directory,doc and analayzer for null conditions but they
all have specific values. I have even tried to execute the sample code provided with the javadoc
API documentation but in vain. 
> Any kind of solutions (including pseudo codes) are welcome 
> Thanks in advance, 
> Sherin George

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message