Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 61031 invoked from network); 16 Dec 2008 10:10:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Dec 2008 10:10:17 -0000 Received: (qmail 45080 invoked by uid 500); 16 Dec 2008 10:10:22 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 44569 invoked by uid 500); 16 Dec 2008 10:10:20 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 44327 invoked by uid 99); 16 Dec 2008 10:10:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Dec 2008 02:10:19 -0800 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ian.lea@gmail.com designates 74.125.92.25 as permitted sender) Received: from [74.125.92.25] (HELO qw-out-2122.google.com) (74.125.92.25) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Dec 2008 10:10:05 +0000 Received: by qw-out-2122.google.com with SMTP id 5so576123qwi.53 for ; Tue, 16 Dec 2008 02:09:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=QH+gzrcAQ8m2ujklDx1HFApRASiciM535MeyBPf3ULA=; b=AIjPrfZg0UPWjHB3jVWGCENe9QMdrMJtsDkUkdCtwI+jXw9DsUNrhX8X8/qxXWFXGC JRc9Fdoz21shs0hStq17OGUS1gbGlhfGAcveh4+wliE9uZuMEIkeN7pDl6A8l9KuFREi ygKBQQsPF0Ik6uBOe6XQPuZrnlCKLLVV0CllI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=gg6dMJnjUU55cJvxCZ5shSEkaZyPwwpOXn9vkBNIBNOrU68Pr9LmCpmrVMT33HnT2w +D2BjNi1sJ0IPWKAxZZgZDkYCLUC2f/Z6Kxfak1WXTcAeV/XMrrgHrxQlltbtZt4pJPt x+T/3mL6WG4rsbzoduY1yUx2VAv18dWkeHhXQ= Received: by 10.214.149.8 with SMTP id w8mr9028797qad.346.1229422182652; Tue, 16 Dec 2008 02:09:42 -0800 (PST) Received: by 10.214.241.6 with HTTP; Tue, 16 Dec 2008 02:09:42 -0800 (PST) Message-ID: <8c4e68610812160209y69230cfbi93cc4381d3b1a6de@mail.gmail.com> Date: Tue, 16 Dec 2008 10:09:42 +0000 From: "Ian Lea" To: java-user@lucene.apache.org Subject: Re: Singleton and Lucene: org.apache.lucene.store.AlreadyClosed In-Reply-To: <21022920.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <20983056.post@talk.nabble.com> <21011945.post@talk.nabble.com> <1C07484A-56A9-4F2E-88E5-B89C3CAAC45B@activemath.org> <21012798.post@talk.nabble.com> <103C3669-84C1-4620-900C-13964D530606@activemath.org> <21022920.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org If the reopen suggestion doesn't fix it, I suggest that you cut down your singleton class to the absolute minimum, wrap it in a junit test case that demonstrates the problem and post the code here. -- Ian. On Mon, Dec 15, 2008 at 10:06 PM, Zender00 wrote: > > Hi Paul, > thanks for your reply. > > I compared your source code and it seems that you are using the same > mechanism for the singleton like me... I am using lucene 2.4 and get the > exception above explained. > I am wondering why because I only create an instance of my lucene object > (which itself constructs an IndexReader/IndexWriter in its constructor) a= nd > return this instance to objects which want to execute some lucene > operations. So I only applied the singleton-pattern. > I am still wondering why these pattern results in my exception. Why could= it > happen, that these Streams (IndexWriter/IndexReader) close itself. In my > opinion it is completely legal to do so. > > Any other suggestions? > > > > polx wrote: >> >> >> Le 15-d=E9c.-08 =E0 13:09, Zender00 a =E9crit : >>> in my opinion it is possible to use a reader and writer >>> simultanesously on >>> the same index. In my already working lucene class, I use they are >>> both open >>> all the time. >> >> mmmh... >> >>> But this isnt the reason for my exception. It seems that lucene cannot >>> handle my singleton. How did you implement your singleton with >>> lucene? Which >>> lucene version? >> >> 2.3.1, source code APL and GPL at: >> http://svn.activemath.org/intergeo/Platform/SearchI2G/index/ >> >> in another project, this was used with Lucene 2.0. >> >> paul >> >>> polx wrote: >>>> >>>> We use singletons all the time, >>>> >>>> Just be careful that are writer and a reader cannot be opened >>>> simultaneously on the same index. Either you write or your read (and >>>> delete). >>>> >>>> paul >>>> >>>> >>>> Le 15-d=E9c.-08 =E0 12:06, Zender00 a =E9crit : >>>> >>>>> >>>>> I extend my original post: >>>>> How is it possible to use lucene in 2 diffent classes / objects, if >>>>> I dont >>>>> want to use static methods/variables? >>>>> (one object read/writer, the other is read only) >>>>> >>>>> Kind regards, >>>>> D. Penning >>>>> >>>>> Zender00 wrote: >>>>>> >>>>>> Hi, >>>>>> I tried to implement a singleton pattern for my already working >>>>>> lucene >>>>>> object. >>>>>> But there is a strange error when I tried to access the instance. >>>>>> >>>>>> When my Singleton GetInstance() method is executed for the first >>>>>> time it >>>>>> creates a new instance of my lucene object. There are some member >>>>>> variables in this object like an IndexWriter and IndexReader. These >>>>>> objects are created in the constructor and I can access them >>>>>> directly in >>>>>> the constructor successfully. >>>>>> GetInstance() now returns this lucene object and I have to execute >>>>>> some >>>>>> operations on it. But the IndexWriter seems to be closed meanwhile >>>>>> and I >>>>>> got the exception: >>>>>> >>>>>> "org.apache.lucene.store.AlreadyClosed Exception: this >>>>>> IndexWriter is >>>>>> closed" when my object tries to writer some documents. >>>>>> >>>>>> How could this happen? Isn't it possible to use lucene with a >>>>>> singleton-pattern? >>>>>> >>>>>> Kind regards, >>>>>> D. Penning >>>>>> >>>>> >>>>> -- >>>>> View this message in context: >>>>> http://www.nabble.com/Singleton-and-Lucene%3A-org.apache.lucene.store= .AlreadyClosed-tp20983056p21011945.html >>>>> Sent from the Lucene - Java Users mailing list archive at >>>>> Nabble.com. >>>>> >>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org >>>>> For additional commands, e-mail: java-user-help@lucene.apache.org >>>>> >>>> >>>> >>>> >>>> >>> >>> -- >>> View this message in context: >>> http://www.nabble.com/Singleton-and-Lucene%3A-org.apache.lucene.store.A= lreadyClosed-tp20983056p21012798.html >>> Sent from the Lucene - Java Users mailing list archive at Nabble.com. >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org >>> For additional commands, e-mail: java-user-help@lucene.apache.org >>> >> >> >> >> > > -- > View this message in context: http://www.nabble.com/Singleton-and-Lucene%= 3A-org.apache.lucene.store.AlreadyClosed-tp20983056p21022920.html > Sent from the Lucene - Java Users mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: java-user-help@lucene.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org