Hi,
Sorry Doron, if the code added in my last mail was confusing and thanks for the reply. The code added in my last mail was not exactly the version that was causing problem, this one is. The lucene version is 1.2. Waiting for a suggestion. Code: public void indexFile(File indexDirFile, File resumeFile) throws IOException { IndexWriter indexwriter = null; try { File afile[] = indexDirFile.listFiles(); boolean flag = false; if (afile.length <= 0) flag = true; indexwriter = new IndexWriter(indexDirFile, new StandardAnalyzer(), flag); doIndexing(indexwriter, resumeFile); // following method if (indexwriter != null) { indexwriter.close(); // <--Indexer.java:150 (Error here) } } catch (IOException e) { e.printStackTrace(); throw new Error(e); } } //-------------------------------------------------------------------------- ----------// public void doIndexing(IndexWriter indexwriter, File resumeFile) { Document document = new Document(); if (resumeFile.getName().endsWith(".pdf")) { ... // Code for indexing PDF docs. Right now the inputs are not PDF docs, // so I have removed this piece as it could not have been causing problems. } else { try { document.add(Field.Text(IndexerColumns.contents, new FileReader(resumeFile))); } catch (FileNotFoundException e) { e.printStackTrace(); throw new MyRuntimeException(e.getMessage(), e); } } for (int i = 0; i < this.columnInfos.length; i++) { ColumnInfo columnInfo = columnInfos[i]; String value = String.valueOf(mapLuceneParams.get(columnInfo.columnName)); if (value != null) { value = value.trim(); if (value.length() != 0) { document.add(Field.Text(columnInfo.columnName, value)); } } } try { indexwriter.addDocument(document); } catch (IOException e) { e.printStackTrace(); throw new MyRuntimeException(e.getMessage(), e); } } } Regards, Shivani Sawhney NetEdge Computing Global Services Private Limited A-14, Sector-7, NOIDA U.P. 201-301 Tel # 91-120-2423281, 2423282 Fax # 91-120-2423279 www.netedgecomputing.com <http://www.netedgecomputing.com/> **************************************************************************** *********************************** Disclaimer: This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation.-----Original Message----- From: Doron Cohen [mailto:[EMAIL PROTECTED] Sent: Friday, October 13, 2006 12:17 PM To: java-user@lucene.apache.org Subject: Re: Error while closing IndexWriter I am far from perfect in this pdf text extracting, however I noticed something in your code that you may want to check to clear up the reason for this failure, see below.. "Shivani Sawhney" <[EMAIL PROTECTED]> wrote on 12/10/2006 22:54:07: > Hi All, > > I am facing a peculiar problem. > > I am trying to index a file and the indexing code executes without any error > but when I try to close the indexer, I get the following error and the error > comes very rarely but when it does, no code on document indexing works and I > finally have to delete all indexes and run a re-indexing utility. > > Can anyone please suggest what might be the problem? > > Stack Trace: > > java.lang.ArrayIndexOutOfBoundsException: 97 >= 17 > at java.util.Vector.elementAt(Vector.java:432) > at > org.apache.lucene.index.FieldInfos.fieldInfo(FieldInfos.java:135) > at > org.apache.lucene.index.FieldsReader.doc(FieldsReader.java:103) > at > org.apache.lucene.index.SegmentReader.document(SegmentReader.java:237) > at > org.apache.lucene.index.SegmentMerger.mergeFields(SegmentMerger.java:169) > at > org.apache.lucene.index.SegmentMerger.merge(SegmentMerger.java:97) > at > org.apache.lucene.index.IndexWriter.mergeSegments(IndexWriter.java:425) > at > org.apache.lucene.index.IndexWriter.flushRamSegments(IndexWriter.java:373) > at > org.apache.lucene.index.IndexWriter.close(IndexWriter.java:193) > at rd.admin.Indexer.indexFile(Indexer.java:150) > ... > ... > try { > indexwriter.addDocument(documentWithCustomFields); Here documentWithCustomFields is added to the index, but the code provided does not handle this doc variable at all... might be just a typo in the code snippet (i.e. if you cleaned it for the mail), or else a real problem in the code, attempting to add to the index the wrong, perhaps null, document? > } catch (IOException e) { > closeIndexWriter(indexwriter); Here, once catching an exception, you are first attempting to close the index and only then print the exception e. So if this "close" line is throwing the exception with the stack trace above, you can't really know that addDocument "executes without any error". Better switch between these 2 lines. > e.printStackTrace(); > throw new MyRuntimeException(e.getMessage(), e); > } > There are 2 calls in your code to closeIndexWriter() and I can't tell which line is Indexer.java:150, is it this one: doIndexing(indexwriter, resumeFile); closeIndexWriter(indexwriter); Or this one: } catch (IOException e) { closeIndexWriter(indexwriter); Hope this helps at all. If not - add some info on the exception, also on the code path taken before getting this error (many ifs in this code), and lucene version used. Regards, Doron --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]