Hi Otis,

Thanks for such a quick reply. I tried using finally, but it didn't help.

I guess if I explain the integration of lucene with my app in little detail
then you probably can help me better.

I allow users to upload documents, which are then indexed, and search on
them. Now I am getting this error when I am trying to index the document and
particularly while closing the index writer.
If we look closely at the error log, it's giving an error at 

org.apache.lucene.index.FieldInfos.fieldInfo(FieldInfos.java:135)

i.e., when lucene tries to get something by the field name, 

return (FieldInfo) byName.get(fieldName);

, now what beats me is that, indexing on fields has already been done by the
time we want to close the index writer, so how come I don't get an error
while indexing, what goes wrong when I am trying to close the index writer.


Please see if you can help me with this....

Thanks in advance.

The code used for indexing is as follows:

    public void indexFile(IndexWriter indexwriter, File resumeFile)
    {
        Document document = new Document();       
        try
        {            
            File afile[] = indexDirFile.listFiles();
            boolean flag = false;

            if (afile.length <= 0)
                flag = true;
            
            indexwriter = new IndexWriter(indexDirFile, new
StandardAnalyzer(), flag);

            try
            {                
                document.add(Field.Text(IndexerColumns.contents, new
FileReader(resumeFile)));
            } catch (FileNotFoundException e)
            {
                e.printStackTrace();
                throw new MyRuntimeException(e.getMessage(), e);
            }
        
        document.add(Field.Keyword( IndexerColumns.id,
String.valueOf(mapLuceneParams.get(IndexerColumns.id)) ));

        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)
                {
                        if (columnInfo.istokenized)
                    {                           
                        document.add(Field.Text(columnInfo.columnName,
value));                        
                    } else
                    {
                        document.add(Field.Keyword(columnInfo.columnName,
value));
                    }
                }
            }
        }
        document.add(Field.Keyword(IndexerColumns.filePath,
String.valueOf(mapLuceneParams.get(IndexerColumns.filePath))));

        try
        {
            indexwriter.addDocument(document); 
        } catch (IOException e)
        {
            e.printStackTrace();
            throw new MyRuntimeException(e.getMessage(), e);
        } 
    
          indexwriter.close();
        } catch (IOException e)
        {   
            e.printStackTrace();
            throw new Error(e);
        }finally
        {
            if(indexwriter != null)
            {
                indexwriter.close();
            }
        }



Regards,
Shivani




-----Original Message-----
From: Otis Gospodnetic [mailto:[EMAIL PROTECTED] 
Sent: 16 February, 2006 10:16 AM
To: java-user@lucene.apache.org
Subject: Re: ArrayIndexOutOfBoundsException while closing the index writer

Who knows what else the app is doing.
However, I can quickly suggest that you add a finally block and close your
writer in there if writer != null.

Otis

----- Original Message ----
From: Shivani Sawhney <[EMAIL PROTECTED]>
To: java-user@lucene.apache.org
Sent: Wednesday, February 15, 2006 11:31:12 PM
Subject: ArrayIndexOutOfBoundsException while closing the index writer

Hi,

I have used Lucene in my application and am just indexing and searching on
some documents. The code that indexes the documents was working fine till
yesterday and suddenly stopped working.

I get an error when I am trying to close the index writer. The code is as
follows:

 

 

.

            IndexWriter indexwriter = new IndexWriter(indexDirFile, new
StandardAnalyzer(), flag);

            indexFile(indexwriter, resumeFile);

            indexwriter.close(); //causing errors

        } catch (IOException e)

        {   

            e.printStackTrace();

            throw new Error(e);

        }

.

 

And the error log is as follows:

 

2006-02-15 18:47:48,748 WARN  [org.apache.struts.action.RequestProcessor]
Unhandled Exception thrown: class java.lang.ArrayIndexOutOfBoundsException

2006-02-15 18:47:48,748 ERROR [org.jboss.web.localhost.Engine]
StandardWrapperValve[action]: Servlet.service() for servlet action threw
exception

java.lang.ArrayIndexOutOfBoundsException: 105 >= 25

            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.NewIndexer.indexTextFile(NewIndexer.java:108)

            at rd.admin.AddResume.indexOneRow(AddResume.java:38)

            at
rd.admin.LuceneGateway.buildMapAndIndex(LuceneGateway.java:46)

            at rd.admin.LuceneGateway.indexResume(LuceneGateway.java:30)

            at
rd.admin.UploadResumeAgainstRequisition.npExecute(UploadResumeAgainstRequisi
tion.java:106)

            at np.core.BaseNPAction.execute(BaseNPAction.java:116)

            at
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProces
sor.java:421)

            at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)

            at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)

            at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)

            at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

            at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)

            at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:237)

            at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:157)

            at
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.ja
va:75)

            at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:186)

            at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:157)

            at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:214)

            at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)

            at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

            at
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContext
Valve.java:198)

            at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:152)

            at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)

            at
org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalVal
ve.java:66)

            at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:102)

            at
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssoci
ationValve.java:153)

            at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:102)

            at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase
.java:540)

            at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:102)

            at
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:
54)

            at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:102)

            at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

            at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137
)

            at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)

            at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118
)

            at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:102)

            at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

            at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:109)

            at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)

            at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

            at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)

            at
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)

            at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)

            at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
ction(Http11Protocol.java:705)

            at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)

            at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:683)

            at java.lang.Thread.run(Thread.java:595)

 

 

 

Can someone please suggest a solution or even the cause of the problem?

 

Thanks in advance.

 

Regards,

Shivani

 





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to