You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Erick Erickson <er...@gmail.com> on 2010/04/30 17:37:25 UTC

Re: [jira] Commented: (LUCENE-2423) NullPointerException when attemping to add a new document to an instance of IndexWriter

if (writer == null) System.out.println("Nope, it didn't open");

This isn't permanent code, just a quick-n-dirty test to see if this
is the root of the error you're seeing.....

Best
Erick

On Fri, Apr 30, 2010 at 11:28 AM, Bill Herbert (JIRA) <ji...@apache.org>wrote:

>
>    [
> https://issues.apache.org/jira/browse/LUCENE-2423?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12862713#action_12862713]
>
> Bill Herbert commented on LUCENE-2423:
> --------------------------------------
>
> Here's the code I used to create IndexWriter instance:
>
> // IndexWriter to use for adding contacts to the index
> final File INDEX_DIR = new File(indexDir);
> IndexWriter writer = new IndexWriter(FSDirectory.open(INDEX_DIR), analyzer,
> createFlag, IndexWriter.MaxFieldLength.LIMITED);
>
> But I'm not sure how to verify the initialization.
>
> > NullPointerException when attemping to add a new document to an instance
> of IndexWriter
> >
> ---------------------------------------------------------------------------------------
> >
> >                 Key: LUCENE-2423
> >                 URL: https://issues.apache.org/jira/browse/LUCENE-2423
> >             Project: Lucene - Java
> >          Issue Type: Bug
> >          Components: Index
> >    Affects Versions: 3.0.1
> >         Environment: Windows Vista Home Premium, Lucene version 3.0.1,
> JRE6, org.apache.commons.digester.Digester,
> org.apache.lucene.index.IndexWriter
> >            Reporter: Bill Herbert
> >             Fix For: 3.0.1
> >
> >   Original Estimate: 168h
> >  Remaining Estimate: 168h
> >
> > I'm attempting to run Listing #4 from "Parsing, Indexing, and Searching
> XML with Digester and Lucene"  <
> https://www.ibm.com/developerworks/library/j-lucene/> .  Using this code
> (with minor modifications), I am able to read and parse an XML input file
> and create a document to be indexed.  However, attempting to index the
> document with an instance of IndexWriter (using the statement:
> writer.addDocument(contactDocument);) causes a NullPointerException with the
> following messages:
> > Apr 29, 2010 2:57:32 PM org.apache.commons.digester.Digester endElement
> > SEVERE: End event threw exception
> > java.lang.reflect.InvocationTargetException
> >         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> >         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> Source)
> >         at java.lang.reflect.Method.invoke(Unknown Source)
> >         at
> org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.jav
> > a:282)
> >         at
> org.apache.commons.digester.SetNextRule.end(SetNextRule.java:217)
> >         at org.apache.commons.digester.Rule.end(Rule.java:253)
> >         at
> org.apache.commons.digester.Digester.endElement(Digester.java:1332)
> >         at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endEleme
> > nt(Unknown Source)
> >         at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
> > l.scanEndElement(Unknown Source)
> >         at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
> > l$FragmentContentDriver.next(Unknown Source)
> >         at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(U
> > nknown Source)
> >         at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
> > l.scanDocument(Unknown Source)
> >         at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(U
> > nknown Source)
> >         at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(U
> > nknown Source)
> >         at
> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown So
> > urce)
> >         at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Un
> > known Source)
> >         at
> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.p
> > arse(Unknown Source)
> >         at org.apache.commons.digester.Digester.parse(Digester.java:1842)
> >         at DigesterMarriesLucene.main(DigesterMarriesLucene.java:94)
> > Caused by: java.lang.NullPointerException
> >         at
> DigesterMarriesLucene.addContact(DigesterMarriesLucene.java:46)
> >         ... 20 more
> > Exception in thread "main" java.lang.NullPointerException
> >         at
> org.apache.commons.digester.Digester.createSAXException(Digester.java
> > :3333)
> >         at
> org.apache.commons.digester.Digester.createSAXException(Digester.java
> > :3359)
> >         at
> org.apache.commons.digester.Digester.endElement(Digester.java:1335)
> >         at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endEleme
> > nt(Unknown Source)
> >         at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
> > l.scanEndElement(Unknown Source)
> >         at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
> > l$FragmentContentDriver.next(Unknown Source)
> >         at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(U
> > nknown Source)
> >         at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
> > l.scanDocument(Unknown Source)
> >         at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(U
> > nknown Source)
> >         at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(U
> > nknown Source)
> >         at
> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown So
> > urce)
> >         at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Un
> > known Source)
> >         at
> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.p
> > arse(Unknown Source)
> >         at org.apache.commons.digester.Digester.parse(Digester.java:1842)
> >         at DigesterMarriesLucene.main(DigesterMarriesLucene.java:94)
> > Caused by: java.lang.NullPointerException
> >         at
> DigesterMarriesLucene.addContact(DigesterMarriesLucene.java:46)
> >         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> >         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> Source)
> >         at java.lang.reflect.Method.invoke(Unknown Source)
> >         at
> org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.jav
> > a:282)
> >         at
> org.apache.commons.digester.SetNextRule.end(SetNextRule.java:217)
> >         at org.apache.commons.digester.Rule.end(Rule.java:253)
> >         at
> org.apache.commons.digester.Digester.endElement(Digester.java:1332)
> >         ... 12 more
>
> --
> 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: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>