lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rupinder Singh Mazara <rsmaz...@ebi.ac.uk>
Subject Re: Null Pointer Exception
Date Thu, 06 Jan 2005 12:02:41 GMT
Do'H , Please disregard the message
forgot to assign the return value when i create the indexreader


Rupinder Singh Mazara wrote:

> Hi all
>  while executing a query  on lucene i get the following execption, if 
> a check for the IndexSearcher object == nulll
>  or a assert i donot get any errors ?  Please help me out on this . 
> java.lang.NullPointerException
>        at 
> org.apache.lucene.search.IndexSearcher.docFreq(IndexSearcher.java:69)
>        at org.apache.lucene.search.Similarity.idf(Similarity.java:255)
>        at 
> org.apache.lucene.search.TermQuery$TermWeight.sumOfSquaredWeights(TermQuery.java:47)

>
>        at 
> org.apache.lucene.search.BooleanQuery$BooleanWeight.sumOfSquaredWeights(BooleanQuery.java:110)

>
>        at org.apache.lucene.search.Query.weight(Query.java:86)
>        at 
> org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:85)
>
> To access the Searchable object I use the following lines of  code, at 
> various places in my web application, all was fine till this morning and
> running command line test scripts does not show a error
>
>  public static IndexReader fetchCitationReader(ServletContext context) 
> throws IOException {
>
>        IndexReader rval = (IndexReader) 
> context.getAttribute("luceneIndexReader");
>
>        if (rval == null) {
>            String var = (String) context.getAttribute("luceneRootName");
>            System.out.println("var = " + var);
>            IndexReader indexReader = IndexReader.open(new File(var));
>            context.setAttribute("luceneIndexReader", indexReader);
>        }
>
>        return rval;
>    }
>
>    public static Searcher fetchCitationSearcher(ServletContext context)
>        throws IOException {
>        Searcher rval = (Searcher) 
> context.getAttribute("luceneSearchable");
>
>        if (rval == null) {
>            rval = new IndexSearcher(fetchCitationReader(context));
>            context.setAttribute("luceneSearchable", rval);
>        }
>
>        return rval;
>    }
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
>


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


Mime
View raw message