lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tatu Saloranta <t...@hypermall.net>
Subject Re: IndexWriter addDocument NullPointerException
Date Sat, 22 Feb 2003 16:32:36 GMT
On Friday 21 February 2003 13:22, Günter Kukies wrote:
> Hello,
>
> I don't have any line number.

You unfortunately do need to know the line number, if you do get an exception 
and try to see where it occurs.
Another less frequent problem is that you actually get the exception as an 
object and print out that exception; in that case you would just see
"java.lang.NullPointerException", and nothing else?
Otherwise, based on your code, you should see a stack trace, with or without
line numbers. But you would at least see the method call stack, which would
help in figuring out where problem occured.

However, if you do catch an exception, and stack trace doesn't have line 
numbers (it seems that some JVMs do not have line number info available when 
running JIT'ed code) there are basically two ways to figure out exact 
location:

(1) Try to make JVM get the line number info (either running in interpreted 
  mode; I think there was option, something like '-Djava.compiler= ' to 
  disable JIT?)
(2) Run code in a debugger. One nice free debugger (if you are not using an
  IDE that has one is JSwat:
     http://www.bluemarsh.com/java/jswat/

Hope this helps,

-+ Tatu +-

>
> this is the code snippet:
>
> Document doc;
> IndexWriter writer;
>
> .....
>
> try{
> writer.addDocument(doc);
> }
> catch(Exception ex){
> ex.printStackTrace();
> }
>
> this is the output on Standard.out:
>
> java.lang.NullPointerException
>
>
> and nothing more.
>
> The doc is not null and System.out.println(doc) seems to be ok. There is
> no difference between the working 80% and the not working 20% doc's.
> Thanks,
>
> Günter
>
> > On Friday 21 February 2003 05:33, Günter Kukies wrote:
> >> Hello,
> >>
> >> writer.addDocument(doc) is throwing an NullPointerException. The
> >> stacktrace from the catched Exception is only one line
> >> "NullPointerException" without anything else. I open the IndexWriter
> >> with create true. Run over the files in a Directory and add all found
> >> documents. After that i close the indexwriter. 80% of the documents
> >> were added without problems. The rest gets that NullPointerException.
> >>
> >> Any Ideas?
> >
> > Perhaps look at the line where the null pointer exception is thrown and
> > see  what happens? NullPointerException is thrown when a null reference
> > is being  de-referenced. Seeing the immediate cause should be easy,
> > given line number.
> >
> > Perhaps you have added a field with null value? (just a guess, I don't
> > know if  that's even illegal).
> >
> > -+ Tatu +-
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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


---------------------------------------------------------------------
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