You forgot to close your writer after the call to optimize.

-----Original Message-----
From: Howk, Michael [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 21, 2002 2:49 PM
To: Lucene Mailing List (E-mail)
Subject: Index Locked For Write


We just got the newest daily build (to try to fix some NullPointer errors
with "?" and "_" characters), and we're getting the same problem that Daniel
Calvo mentioned: Index Locked for Write. Here's basically what our code is
doing:
      IndexWriter writer = new IndexWriter(path, analyzer, create);
        try {
            Document doc = new Document();            
            doc.add(Field.Keyword("DOC_ID", "14"));
          doc.add(Field.UnStored("ANY", "mushu"));
          writer.addDocument(doc);
          writer.optimize();

          // Search the document for our keyword
          {   
          IndexReader reader = IndexReader.open(path);
          IndexSearcher searcher = new IndexSearcher(reader);
          Vector returnStuff = searcher.search("mushu");
          }
            
          // Verify that we got one record back
          assertNotNull(returnStuff);
          assertEquals(1, returnStuff.size());
      }
      finally {
          // Clean up after ourselves
          IndexReader reader = IndexReader.open(path);
          reader.delete(new Term("DOC_ID", "14"));
          reader.close();
      }

And the exception we're getting on the "reader.delete" line in the finally
clause:

java.io.IOException: Index locked for write:
Lock@C:\devtools\JBossTomcat\jboss\indexes\marc\write.lock at
sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteC
all.java:245) at
sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220) at
sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122) at
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker_Stub.invoke(Unknown
Source) at
org.jboss.ejb.plugins.jrmp.interfaces.GenericProxy.invokeContainer(GenericPr
oxy.java:357) at
org.jboss.ejb.plugins.jrmp.interfaces.StatelessSessionProxy.invoke(Stateless
SessionProxy.java:123) at
$Proxy5.deleteDocument(Unknown Source)

Are we using the right approach? Any suggestions? Thank you.

Michael Howk

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


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

Reply via email to