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 Günter Kukies <gu...@heuft.com> on 2003/02/21 13:33:36 UTC

IndexWriter addDocument NullPointerException

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?


Thanks

Günter

Re: IndexWriter addDocument NullPointerException

Posted by Günter Kukies <gu...@heuft.com>.
The code is running as a servlet within tomcat.
The output is piped to catalina.out

 >> "$CATALINA_BASE"/logs/catalina.out 2>&1 &

so I see standard.out and err

Günter



> Günter Kukies wrote:
>
>>Hello,
>>
>>I don't have any line number.
>>
>>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
>>
>>
> printStackTrace() prints to standard err, not standard out.
>
>
>
> ---------------------------------------------------------------------
> 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


Re: IndexWriter addDocument NullPointerException

Posted by ne...@hotu.com.
Günter Kukies wrote:

>Hello,
>
>I don't have any line number.
>
>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
>  
>
printStackTrace() prints to standard err, not standard out.



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


Re: IndexWriter addDocument NullPointerException

Posted by Günter Kukies <gu...@heuft.com>.
System information:

JDK 1.4.1_01
tomcat 4.0.3
Linux SuSE 7.3 (i386) - Kernal 2.4.10-4GB
Lucene 1.2 final

user for documents is root/root
mode for documents is 0766

user for lucene generated files is root/root
mode for lucene generated files is 0644

----- Original Message -----
From: "Günter Kukies" <gu...@heuft.com>
To: "Lucene Users List" <lu...@jakarta.apache.org>
Sent: Monday, February 24, 2003 8:22 AM
Subject: Re: IndexWriter addDocument NullPointerException


> So, weekend is over.
>
> here is some code :
>
>    private void addDocument(IndexWriter writer, File file ) throws
> IOException, InterruptedException {
>         String path = file.getName();
>         log( "-------------start Indexing:" + path );
>         Document doc = null;
>         if(path.matches("\\d+_\\d{4}_[a-z]{2,3}\\.pdf")) {
>             doc = PDF_Document_Parser.getDocument(this,RealPath,file);
>         }
>         else if(path.matches("\\d+_\\d{4}_[a-z]{2,3}\\.txt")) {
>             doc = TXT_Document_Parser.getDocument(this,RealPath,file);
>         }
>         else {
>             log("do nothing");
>         }
>
>         log("doc: "+doc);
>         if( doc != null ) {
>             try {
>                 writer.addDocument(doc);
>             }
>             catch(Exception ex) {
>                 System.err.println("hallo1 "+doc);
>                 ex.printStackTrace();
>                 System.err.println("hallo2");
>                 log("ERROR writer.addDocument(doc);");
>             }
>         }
>         else {
>             log( "Skipping " + path );
>         }
>         log( "-------------end Indexing:" + path );
>     }
>
>
>
> Here is the output:
>
> hallo1 Document<Te...@18a3a1d>
> Unindexed<em...@xxx.com> Unindexed<name:Hans Dampf>
> Text<summary:Equipo de deteccion 2002> Text<title:Equipo de deteccion
2002>
> Text<doctypeid:0001> Unindexed<lifetime:0>
> org.apache.lucene.document.Field@1ed688f Keyword<modified:0dcek766w>
> Keyword<username:hda>
>
Unindexed<relative_path_xml:documents/news_new/sub1/sub11/sub111/10457359746
> 80_0001_hda.xml> Unindexed<category:documents/news_new/sub1/sub11/sub111/>
> Keyword<search_all:all> org.apache.lucene.document.Field@16b98c3
>
Unindexed<relative_path:documents/news_new/sub1/sub11/sub111/1045735974680_0
> 001_hda.pdf>>
> java.lang.NullPointerException
> hallo2
> hallo1 Document<Te...@c12978>
> Unindexed<em...@xxx.com> Unindexed<name:Hans Dampf>
> Text<summary:testsummary> Text<title:testtitle> Text<doctypeid:0001>
> Unindexed<lifetime:0> org.apache.lucene.document.Field@189c12a
> Keyword<modified:0dcek76bm> Keyword<username:hda>
>
Unindexed<relative_path_xml:documents/news_new/sub1/sub11/sub111/10457359748
> 50_0001_hda.xml> Unindexed<category:documents/news_new/sub1/sub11/sub111/>
> Keyword<search_all:all> org.apache.lucene.document.Field@e8c7db
>
Unindexed<relative_path:documents/news_new/sub1/sub11/sub111/1045735974850_0
> 001_hda.pdf>>
> java.lang.NullPointerException
> hallo2
>
> Günter
>
> ----- Original Message -----
> From: "Tatu Saloranta" <ta...@hypermall.net>
> To: "Lucene Users List" <lu...@jakarta.apache.org>
> Sent: Saturday, February 22, 2003 5:32 PM
> Subject: Re: IndexWriter addDocument NullPointerException
>
>
> > 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
> >
> >
>
>
> ---------------------------------------------------------------------
> 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


Re: IndexWriter addDocument NullPointerException

Posted by Günter Kukies <gu...@heuft.com>.
I switched off the -server switch from the java commandline options and
everything works fine now.
I changed nothing in my code.

So is it principly possible to throw an Exception with not stack trace?

Any comments about this phenomenon?

Günter


----- Original Message -----
From: "Otis Gospodnetic" <ot...@yahoo.com>
To: "Lucene Users List" <lu...@jakarta.apache.org>
Sent: Monday, February 24, 2003 4:31 PM
Subject: Re: IndexWriter addDocument NullPointerException


> If I were you I would make things simpler for myself by converting the
> code to something that I could run from the command line instead of
> having to go through Tomcat.
>
> You really need to capture your exception stack trace with lne numbers,
> and then we can try helping.
>
> Otis
>
>
> --- Günter_Kukies <gu...@heuft.com> wrote:
> > log("doc: "+doc); is handled by tomcat and directed into special
> > log-files,
> > so you can't see them.
> >
> > > >                 System.err.println("hallo1 "+doc);
> > > >                 ex.printStackTrace();
> > > >                 System.err.println("hallo2");
> > this is printing the relevant output.
> >
> > doc is never null, writer is never null and I can't add null-fields
> > to a
> > document.
> >
> >
> > Günter
> >
> > ----- Original Message -----
> > From: "Otis Gospodnetic" <ot...@yahoo.com>
> > To: "Lucene Users List" <lu...@jakarta.apache.org>
> > Sent: Monday, February 24, 2003 3:07 PM
> > Subject: Re: IndexWriter addDocument NullPointerException
> >
> >
> > > My guess is that your 2 getDocument calls are the source, that is,
> > that
> > > those PDF and TXT classes don't return a proper Document.
> > > I also don't see the output created by log("doc: "+doc);
> > >
> > > Otis
> > >
> > >
> > >         if(path.matches("\\d+_\\d{4}_[a-z]{2,3}\\.pdf")) {
> > >             doc =
> > PDF_Document_Parser.getDocument(this,RealPath,file);
> > >         }
> > >         else if(path.matches("\\d+_\\d{4}_[a-z]{2,3}\\.txt")) {
> > >             doc =
> > TXT_Document_Parser.getDocument(this,RealPath,file);
> > >         }
> > >
> > >
> > > --- Günter_Kukies <gu...@heuft.com> wrote:
> > > > So, weekend is over.
> > > >
> > > > here is some code :
> > > >
> > > >    private void addDocument(IndexWriter writer, File file )
> > throws
> > > > IOException, InterruptedException {
> > > >         String path = file.getName();
> > > >         log( "-------------start Indexing:" + path );
> > > >         Document doc = null;
> > > >         if(path.matches("\\d+_\\d{4}_[a-z]{2,3}\\.pdf")) {
> > > >             doc =
> > > > PDF_Document_Parser.getDocument(this,RealPath,file);
> > > >         }
> > > >         else if(path.matches("\\d+_\\d{4}_[a-z]{2,3}\\.txt")) {
> > > >             doc =
> > > > TXT_Document_Parser.getDocument(this,RealPath,file);
> > > >         }
> > > >         else {
> > > >             log("do nothing");
> > > >         }
> > > >
> > > >         log("doc: "+doc);
> > > >         if( doc != null ) {
> > > >             try {
> > > >                 writer.addDocument(doc);
> > > >             }
> > > >             catch(Exception ex) {
> > > >                 System.err.println("hallo1 "+doc);
> > > >                 ex.printStackTrace();
> > > >                 System.err.println("hallo2");
> > > >                 log("ERROR writer.addDocument(doc);");
> > > >             }
> > > >         }
> > > >         else {
> > > >             log( "Skipping " + path );
> > > >         }
> > > >         log( "-------------end Indexing:" + path );
> > > >     }
> > > >
> > > >
> > > >
> > > > Here is the output:
> > > >
> > > > hallo1 Document<Te...@18a3a1d>
> > > > Unindexed<em...@xxx.com> Unindexed<name:Hans Dampf>
> > > > Text<summary:Equipo de deteccion 2002> Text<title:Equipo de
> > deteccion
> > > > 2002>
> > > > Text<doctypeid:0001> Unindexed<lifetime:0>
> > > > org.apache.lucene.document.Field@1ed688f
> > Keyword<modified:0dcek766w>
> > > > Keyword<username:hda>
> > > >
> > >
> >
>
Unindexed<relative_path_xml:documents/news_new/sub1/sub11/sub111/10457359746
> > > > 80_0001_hda.xml>
> > > > Unindexed<category:documents/news_new/sub1/sub11/sub111/>
> > > > Keyword<search_all:all> org.apache.lucene.document.Field@16b98c3
> > > >
> > >
> >
>
Unindexed<relative_path:documents/news_new/sub1/sub11/sub111/1045735974680_0
> > > > 001_hda.pdf>>
> > > > java.lang.NullPointerException
> > > > hallo2
> > > > hallo1 Document<Te...@c12978>
> > > > Unindexed<em...@xxx.com> Unindexed<name:Hans Dampf>
> > > > Text<summary:testsummary> Text<title:testtitle>
> > Text<doctypeid:0001>
> > > > Unindexed<lifetime:0> org.apache.lucene.document.Field@189c12a
> > > > Keyword<modified:0dcek76bm> Keyword<username:hda>
> > > >
> > >
> >
>
Unindexed<relative_path_xml:documents/news_new/sub1/sub11/sub111/10457359748
> > > > 50_0001_hda.xml>
> > > > Unindexed<category:documents/news_new/sub1/sub11/sub111/>
> > > > Keyword<search_all:all> org.apache.lucene.document.Field@e8c7db
> > > >
> > >
> >
>
Unindexed<relative_path:documents/news_new/sub1/sub11/sub111/1045735974850_0
> > > > 001_hda.pdf>>
> > > > java.lang.NullPointerException
> > > > hallo2
> > > >
> > > > Günter
> > > >
> > > > ----- Original Message -----
> > > > From: "Tatu Saloranta" <ta...@hypermall.net>
> > > > To: "Lucene Users List" <lu...@jakarta.apache.org>
> > > > Sent: Saturday, February 22, 2003 5:32 PM
> > > > Subject: Re: IndexWriter addDocument NullPointerException
> > > >
> > > >
> > > > > 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 +-
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - forms, calculators, tips, more
> http://taxes.yahoo.com/
>
> ---------------------------------------------------------------------
> 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


Re: IndexWriter addDocument NullPointerException

Posted by Otis Gospodnetic <ot...@yahoo.com>.
If I were you I would make things simpler for myself by converting the
code to something that I could run from the command line instead of
having to go through Tomcat.

You really need to capture your exception stack trace with lne numbers,
and then we can try helping.

Otis


--- G�nter_Kukies <gu...@heuft.com> wrote:
> log("doc: "+doc); is handled by tomcat and directed into special
> log-files,
> so you can't see them.
> 
> > >                 System.err.println("hallo1 "+doc);
> > >                 ex.printStackTrace();
> > >                 System.err.println("hallo2");
> this is printing the relevant output.
> 
> doc is never null, writer is never null and I can't add null-fields
> to a
> document.
> 
> 
> G�nter
> 
> ----- Original Message -----
> From: "Otis Gospodnetic" <ot...@yahoo.com>
> To: "Lucene Users List" <lu...@jakarta.apache.org>
> Sent: Monday, February 24, 2003 3:07 PM
> Subject: Re: IndexWriter addDocument NullPointerException
> 
> 
> > My guess is that your 2 getDocument calls are the source, that is,
> that
> > those PDF and TXT classes don't return a proper Document.
> > I also don't see the output created by log("doc: "+doc);
> >
> > Otis
> >
> >
> >         if(path.matches("\\d+_\\d{4}_[a-z]{2,3}\\.pdf")) {
> >             doc =
> PDF_Document_Parser.getDocument(this,RealPath,file);
> >         }
> >         else if(path.matches("\\d+_\\d{4}_[a-z]{2,3}\\.txt")) {
> >             doc =
> TXT_Document_Parser.getDocument(this,RealPath,file);
> >         }
> >
> >
> > --- G�nter_Kukies <gu...@heuft.com> wrote:
> > > So, weekend is over.
> > >
> > > here is some code :
> > >
> > >    private void addDocument(IndexWriter writer, File file )
> throws
> > > IOException, InterruptedException {
> > >         String path = file.getName();
> > >         log( "-------------start Indexing:" + path );
> > >         Document doc = null;
> > >         if(path.matches("\\d+_\\d{4}_[a-z]{2,3}\\.pdf")) {
> > >             doc =
> > > PDF_Document_Parser.getDocument(this,RealPath,file);
> > >         }
> > >         else if(path.matches("\\d+_\\d{4}_[a-z]{2,3}\\.txt")) {
> > >             doc =
> > > TXT_Document_Parser.getDocument(this,RealPath,file);
> > >         }
> > >         else {
> > >             log("do nothing");
> > >         }
> > >
> > >         log("doc: "+doc);
> > >         if( doc != null ) {
> > >             try {
> > >                 writer.addDocument(doc);
> > >             }
> > >             catch(Exception ex) {
> > >                 System.err.println("hallo1 "+doc);
> > >                 ex.printStackTrace();
> > >                 System.err.println("hallo2");
> > >                 log("ERROR writer.addDocument(doc);");
> > >             }
> > >         }
> > >         else {
> > >             log( "Skipping " + path );
> > >         }
> > >         log( "-------------end Indexing:" + path );
> > >     }
> > >
> > >
> > >
> > > Here is the output:
> > >
> > > hallo1 Document<Te...@18a3a1d>
> > > Unindexed<em...@xxx.com> Unindexed<name:Hans Dampf>
> > > Text<summary:Equipo de deteccion 2002> Text<title:Equipo de
> deteccion
> > > 2002>
> > > Text<doctypeid:0001> Unindexed<lifetime:0>
> > > org.apache.lucene.document.Field@1ed688f
> Keyword<modified:0dcek766w>
> > > Keyword<username:hda>
> > >
> >
>
Unindexed<relative_path_xml:documents/news_new/sub1/sub11/sub111/10457359746
> > > 80_0001_hda.xml>
> > > Unindexed<category:documents/news_new/sub1/sub11/sub111/>
> > > Keyword<search_all:all> org.apache.lucene.document.Field@16b98c3
> > >
> >
>
Unindexed<relative_path:documents/news_new/sub1/sub11/sub111/1045735974680_0
> > > 001_hda.pdf>>
> > > java.lang.NullPointerException
> > > hallo2
> > > hallo1 Document<Te...@c12978>
> > > Unindexed<em...@xxx.com> Unindexed<name:Hans Dampf>
> > > Text<summary:testsummary> Text<title:testtitle>
> Text<doctypeid:0001>
> > > Unindexed<lifetime:0> org.apache.lucene.document.Field@189c12a
> > > Keyword<modified:0dcek76bm> Keyword<username:hda>
> > >
> >
>
Unindexed<relative_path_xml:documents/news_new/sub1/sub11/sub111/10457359748
> > > 50_0001_hda.xml>
> > > Unindexed<category:documents/news_new/sub1/sub11/sub111/>
> > > Keyword<search_all:all> org.apache.lucene.document.Field@e8c7db
> > >
> >
>
Unindexed<relative_path:documents/news_new/sub1/sub11/sub111/1045735974850_0
> > > 001_hda.pdf>>
> > > java.lang.NullPointerException
> > > hallo2
> > >
> > > G�nter
> > >
> > > ----- Original Message -----
> > > From: "Tatu Saloranta" <ta...@hypermall.net>
> > > To: "Lucene Users List" <lu...@jakarta.apache.org>
> > > Sent: Saturday, February 22, 2003 5:32 PM
> > > Subject: Re: IndexWriter addDocument NullPointerException
> > >
> > >
> > > > 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 +-


__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/

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


Re: IndexWriter addDocument NullPointerException

Posted by Günter Kukies <gu...@heuft.com>.
log("doc: "+doc); is handled by tomcat and directed into special log-files,
so you can't see them.

> >                 System.err.println("hallo1 "+doc);
> >                 ex.printStackTrace();
> >                 System.err.println("hallo2");
this is printing the relevant output.

doc is never null, writer is never null and I can't add null-fields to a
document.


Günter

----- Original Message -----
From: "Otis Gospodnetic" <ot...@yahoo.com>
To: "Lucene Users List" <lu...@jakarta.apache.org>
Sent: Monday, February 24, 2003 3:07 PM
Subject: Re: IndexWriter addDocument NullPointerException


> My guess is that your 2 getDocument calls are the source, that is, that
> those PDF and TXT classes don't return a proper Document.
> I also don't see the output created by log("doc: "+doc);
>
> Otis
>
>
>         if(path.matches("\\d+_\\d{4}_[a-z]{2,3}\\.pdf")) {
>             doc = PDF_Document_Parser.getDocument(this,RealPath,file);
>         }
>         else if(path.matches("\\d+_\\d{4}_[a-z]{2,3}\\.txt")) {
>             doc = TXT_Document_Parser.getDocument(this,RealPath,file);
>         }
>
>
> --- Günter_Kukies <gu...@heuft.com> wrote:
> > So, weekend is over.
> >
> > here is some code :
> >
> >    private void addDocument(IndexWriter writer, File file ) throws
> > IOException, InterruptedException {
> >         String path = file.getName();
> >         log( "-------------start Indexing:" + path );
> >         Document doc = null;
> >         if(path.matches("\\d+_\\d{4}_[a-z]{2,3}\\.pdf")) {
> >             doc =
> > PDF_Document_Parser.getDocument(this,RealPath,file);
> >         }
> >         else if(path.matches("\\d+_\\d{4}_[a-z]{2,3}\\.txt")) {
> >             doc =
> > TXT_Document_Parser.getDocument(this,RealPath,file);
> >         }
> >         else {
> >             log("do nothing");
> >         }
> >
> >         log("doc: "+doc);
> >         if( doc != null ) {
> >             try {
> >                 writer.addDocument(doc);
> >             }
> >             catch(Exception ex) {
> >                 System.err.println("hallo1 "+doc);
> >                 ex.printStackTrace();
> >                 System.err.println("hallo2");
> >                 log("ERROR writer.addDocument(doc);");
> >             }
> >         }
> >         else {
> >             log( "Skipping " + path );
> >         }
> >         log( "-------------end Indexing:" + path );
> >     }
> >
> >
> >
> > Here is the output:
> >
> > hallo1 Document<Te...@18a3a1d>
> > Unindexed<em...@xxx.com> Unindexed<name:Hans Dampf>
> > Text<summary:Equipo de deteccion 2002> Text<title:Equipo de deteccion
> > 2002>
> > Text<doctypeid:0001> Unindexed<lifetime:0>
> > org.apache.lucene.document.Field@1ed688f Keyword<modified:0dcek766w>
> > Keyword<username:hda>
> >
>
Unindexed<relative_path_xml:documents/news_new/sub1/sub11/sub111/10457359746
> > 80_0001_hda.xml>
> > Unindexed<category:documents/news_new/sub1/sub11/sub111/>
> > Keyword<search_all:all> org.apache.lucene.document.Field@16b98c3
> >
>
Unindexed<relative_path:documents/news_new/sub1/sub11/sub111/1045735974680_0
> > 001_hda.pdf>>
> > java.lang.NullPointerException
> > hallo2
> > hallo1 Document<Te...@c12978>
> > Unindexed<em...@xxx.com> Unindexed<name:Hans Dampf>
> > Text<summary:testsummary> Text<title:testtitle> Text<doctypeid:0001>
> > Unindexed<lifetime:0> org.apache.lucene.document.Field@189c12a
> > Keyword<modified:0dcek76bm> Keyword<username:hda>
> >
>
Unindexed<relative_path_xml:documents/news_new/sub1/sub11/sub111/10457359748
> > 50_0001_hda.xml>
> > Unindexed<category:documents/news_new/sub1/sub11/sub111/>
> > Keyword<search_all:all> org.apache.lucene.document.Field@e8c7db
> >
>
Unindexed<relative_path:documents/news_new/sub1/sub11/sub111/1045735974850_0
> > 001_hda.pdf>>
> > java.lang.NullPointerException
> > hallo2
> >
> > Günter
> >
> > ----- Original Message -----
> > From: "Tatu Saloranta" <ta...@hypermall.net>
> > To: "Lucene Users List" <lu...@jakarta.apache.org>
> > Sent: Saturday, February 22, 2003 5:32 PM
> > Subject: Re: IndexWriter addDocument NullPointerException
> >
> >
> > > 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
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: lucene-user-help@jakarta.apache.org
> >
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - forms, calculators, tips, more
> http://taxes.yahoo.com/
>
> ---------------------------------------------------------------------
> 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


Re: IndexWriter addDocument NullPointerException

Posted by Otis Gospodnetic <ot...@yahoo.com>.
My guess is that your 2 getDocument calls are the source, that is, that
those PDF and TXT classes don't return a proper Document.
I also don't see the output created by log("doc: "+doc);

Otis


        if(path.matches("\\d+_\\d{4}_[a-z]{2,3}\\.pdf")) {
            doc = PDF_Document_Parser.getDocument(this,RealPath,file);
        }
        else if(path.matches("\\d+_\\d{4}_[a-z]{2,3}\\.txt")) {
            doc = TXT_Document_Parser.getDocument(this,RealPath,file);
        }


--- G�nter_Kukies <gu...@heuft.com> wrote:
> So, weekend is over.
> 
> here is some code :
> 
>    private void addDocument(IndexWriter writer, File file ) throws
> IOException, InterruptedException {
>         String path = file.getName();
>         log( "-------------start Indexing:" + path );
>         Document doc = null;
>         if(path.matches("\\d+_\\d{4}_[a-z]{2,3}\\.pdf")) {
>             doc =
> PDF_Document_Parser.getDocument(this,RealPath,file);
>         }
>         else if(path.matches("\\d+_\\d{4}_[a-z]{2,3}\\.txt")) {
>             doc =
> TXT_Document_Parser.getDocument(this,RealPath,file);
>         }
>         else {
>             log("do nothing");
>         }
> 
>         log("doc: "+doc);
>         if( doc != null ) {
>             try {
>                 writer.addDocument(doc);
>             }
>             catch(Exception ex) {
>                 System.err.println("hallo1 "+doc);
>                 ex.printStackTrace();
>                 System.err.println("hallo2");
>                 log("ERROR writer.addDocument(doc);");
>             }
>         }
>         else {
>             log( "Skipping " + path );
>         }
>         log( "-------------end Indexing:" + path );
>     }
> 
> 
> 
> Here is the output:
> 
> hallo1 Document<Te...@18a3a1d>
> Unindexed<em...@xxx.com> Unindexed<name:Hans Dampf>
> Text<summary:Equipo de deteccion 2002> Text<title:Equipo de deteccion
> 2002>
> Text<doctypeid:0001> Unindexed<lifetime:0>
> org.apache.lucene.document.Field@1ed688f Keyword<modified:0dcek766w>
> Keyword<username:hda>
>
Unindexed<relative_path_xml:documents/news_new/sub1/sub11/sub111/10457359746
> 80_0001_hda.xml>
> Unindexed<category:documents/news_new/sub1/sub11/sub111/>
> Keyword<search_all:all> org.apache.lucene.document.Field@16b98c3
>
Unindexed<relative_path:documents/news_new/sub1/sub11/sub111/1045735974680_0
> 001_hda.pdf>>
> java.lang.NullPointerException
> hallo2
> hallo1 Document<Te...@c12978>
> Unindexed<em...@xxx.com> Unindexed<name:Hans Dampf>
> Text<summary:testsummary> Text<title:testtitle> Text<doctypeid:0001>
> Unindexed<lifetime:0> org.apache.lucene.document.Field@189c12a
> Keyword<modified:0dcek76bm> Keyword<username:hda>
>
Unindexed<relative_path_xml:documents/news_new/sub1/sub11/sub111/10457359748
> 50_0001_hda.xml>
> Unindexed<category:documents/news_new/sub1/sub11/sub111/>
> Keyword<search_all:all> org.apache.lucene.document.Field@e8c7db
>
Unindexed<relative_path:documents/news_new/sub1/sub11/sub111/1045735974850_0
> 001_hda.pdf>>
> java.lang.NullPointerException
> hallo2
> 
> G�nter
> 
> ----- Original Message -----
> From: "Tatu Saloranta" <ta...@hypermall.net>
> To: "Lucene Users List" <lu...@jakarta.apache.org>
> Sent: Saturday, February 22, 2003 5:32 PM
> Subject: Re: IndexWriter addDocument NullPointerException
> 
> 
> > 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
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/

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


Re: IndexWriter addDocument NullPointerException

Posted by Günter Kukies <gu...@heuft.com>.
So, weekend is over.

here is some code :

   private void addDocument(IndexWriter writer, File file ) throws
IOException, InterruptedException {
        String path = file.getName();
        log( "-------------start Indexing:" + path );
        Document doc = null;
        if(path.matches("\\d+_\\d{4}_[a-z]{2,3}\\.pdf")) {
            doc = PDF_Document_Parser.getDocument(this,RealPath,file);
        }
        else if(path.matches("\\d+_\\d{4}_[a-z]{2,3}\\.txt")) {
            doc = TXT_Document_Parser.getDocument(this,RealPath,file);
        }
        else {
            log("do nothing");
        }

        log("doc: "+doc);
        if( doc != null ) {
            try {
                writer.addDocument(doc);
            }
            catch(Exception ex) {
                System.err.println("hallo1 "+doc);
                ex.printStackTrace();
                System.err.println("hallo2");
                log("ERROR writer.addDocument(doc);");
            }
        }
        else {
            log( "Skipping " + path );
        }
        log( "-------------end Indexing:" + path );
    }



Here is the output:

hallo1 Document<Te...@18a3a1d>
Unindexed<em...@xxx.com> Unindexed<name:Hans Dampf>
Text<summary:Equipo de deteccion 2002> Text<title:Equipo de deteccion 2002>
Text<doctypeid:0001> Unindexed<lifetime:0>
org.apache.lucene.document.Field@1ed688f Keyword<modified:0dcek766w>
Keyword<username:hda>
Unindexed<relative_path_xml:documents/news_new/sub1/sub11/sub111/10457359746
80_0001_hda.xml> Unindexed<category:documents/news_new/sub1/sub11/sub111/>
Keyword<search_all:all> org.apache.lucene.document.Field@16b98c3
Unindexed<relative_path:documents/news_new/sub1/sub11/sub111/1045735974680_0
001_hda.pdf>>
java.lang.NullPointerException
hallo2
hallo1 Document<Te...@c12978>
Unindexed<em...@xxx.com> Unindexed<name:Hans Dampf>
Text<summary:testsummary> Text<title:testtitle> Text<doctypeid:0001>
Unindexed<lifetime:0> org.apache.lucene.document.Field@189c12a
Keyword<modified:0dcek76bm> Keyword<username:hda>
Unindexed<relative_path_xml:documents/news_new/sub1/sub11/sub111/10457359748
50_0001_hda.xml> Unindexed<category:documents/news_new/sub1/sub11/sub111/>
Keyword<search_all:all> org.apache.lucene.document.Field@e8c7db
Unindexed<relative_path:documents/news_new/sub1/sub11/sub111/1045735974850_0
001_hda.pdf>>
java.lang.NullPointerException
hallo2

Günter

----- Original Message -----
From: "Tatu Saloranta" <ta...@hypermall.net>
To: "Lucene Users List" <lu...@jakarta.apache.org>
Sent: Saturday, February 22, 2003 5:32 PM
Subject: Re: IndexWriter addDocument NullPointerException


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


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


Re: IndexWriter addDocument NullPointerException

Posted by Tatu Saloranta <ta...@hypermall.net>.
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


Re: IndexWriter addDocument NullPointerException

Posted by Günter Kukies <gu...@heuft.com>.
Hello,

I don't have any line number.

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


Re: IndexWriter addDocument NullPointerException

Posted by Tatu Saloranta <ta...@hypermall.net>.
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