You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Rupinder Singh Mazara <rs...@ebi.ac.uk> on 2005/01/06 12:46:10 UTC
Null Pointer Exception
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
Re: Null Pointer Exception
Posted by Rupinder Singh Mazara <rs...@ebi.ac.uk>.
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