Return-Path: Delivered-To: apmail-jakarta-lucene-user-archive@www.apache.org Received: (qmail 58541 invoked from network); 7 Sep 2004 22:48:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 7 Sep 2004 22:48:25 -0000 Received: (qmail 32315 invoked by uid 500); 7 Sep 2004 22:48:18 -0000 Delivered-To: apmail-jakarta-lucene-user-archive@jakarta.apache.org Received: (qmail 32294 invoked by uid 500); 7 Sep 2004 22:48:17 -0000 Mailing-List: contact lucene-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Lucene Users List" Reply-To: "Lucene Users List" Delivered-To: mailing list lucene-user@jakarta.apache.org Received: (qmail 32281 invoked by uid 99); 7 Sep 2004 22:48:17 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=RCVD_BY_IP,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of pburleson@gmail.com designates 64.233.170.207 as permitted sender) Received: from [64.233.170.207] (HELO mproxy.gmail.com) (64.233.170.207) by apache.org (qpsmtpd/0.28) with ESMTP; Tue, 07 Sep 2004 15:48:16 -0700 Received: by mproxy.gmail.com with SMTP id 78so278433rnl for ; Tue, 07 Sep 2004 15:48:15 -0700 (PDT) Received: by 10.38.78.70 with SMTP id a70mr2314111rnb; Tue, 07 Sep 2004 15:48:15 -0700 (PDT) Received: by 10.38.78.12 with HTTP; Tue, 7 Sep 2004 15:48:15 -0700 (PDT) Message-ID: Date: Tue, 7 Sep 2004 18:48:15 -0400 From: Patrick Burleson Reply-To: Patrick Burleson To: hui liu Subject: Re: lucene locks index, tomcat has to stop and restart Cc: Lucene Users List In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Ah, I see your problem. From the Lucene Javadocs on IndexSearcher.close(): "Note that the underlying IndexReader is not closed, if IndexSearcher was constructed with IndexSearcher(IndexReader r). If the IndexReader was supplied implicitly by specifying a directory, then the IndexReader gets closed." Since you are explicitly passing in an IndexReader, the IndexSearcher is not closing it. But since you created the IndexReader without retaining a reference to it, you can not close it, thus you will always have an open index. You have a couple of options: Either retain a reference to IndexReader by doing the following: IndexReader ir = IndexReader.open(indexName); IndexSearcher searcher = new IndexSearcher(ir); or if indexName is just the path to the index, then just use: IndexSearcher searcher = new IndexSearcher(indexName); since that will manage the IndexReader for you. Hope that helps. Patrick CCing list for archives. On Tue, 7 Sep 2004 18:38:43 -0400, hui liu wrote: > First of all, thanks for your reply:-) > > But actually, I've already tried this and here is my code: > > searcher = new IndexSearcher(IndexReader.open(indexName)); > > and at some later place I wrote: > > IndexReader.close(); > > Both of them are within try and catch, and then I got such an error in > IE by tomcat: > > non-static method close() cannot be referenced from a static context. > > I read the source code of IndexReader and found that the method > close() is final not static. so I tried to change it to static, but > got even more errors. > > I am wondering how do you use lucene? Has anyone met with the same thing? > > Thanks a lot. > > Ivy. > > > > > On Tue, 7 Sep 2004 17:03:00 -0400, Patrick Burleson wrote: > > This isn't a Tomcat specific problem, but sounds like a problem with > > how you the reader is being used. > > > > Somewhere in the JSP a IndexReader variable was probably assigned to. > > A line something like: > > > > IndexReader ir = IndexReader.open("somepath"); > > > > To close the reader, and thus solve the problem, somewhere later, you need: > > > > ir.close(); > > > > with the needed try/catch in place. > > > > Again, please refrain from cross-posting...just because it happened on > > Tomcat doesn't make it a Tomcat problem. This is clearly a lucene > > usage problem. > > > > Patrick > > > > > > > > On Tue, 7 Sep 2004 16:37:42 -0400, hui liu wrote: > > > Hi, > > > > > > I met with such a problem with lucene demo: > > > > > > Each time when I create lucene index, I have to first stop tomcat, and > > > restart tomcat after the index is created. The reason is: the index is > > > locked when using IndexReader.open(index) method in the jsp file. > > > > > > So, I tried to modify the jsp codes by adding close(), but it shows > > > error which said "close() is not a static method". I checked the > > > source codes of lucene IndexReader methods, and found that the close() > > > method is final not static. I tried to change it to static, but > > > resulted in many errors. > > > > > > So, does anybody meet the similar problem as me? Do you have any solutions? > > > > > > Thank you very very much.....!! > > > > > > Ivy. > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org > > > For additional commands, e-mail: tomcat-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