Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 72583 invoked from network); 3 Oct 2008 22:39:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Oct 2008 22:39:06 -0000 Received: (qmail 48975 invoked by uid 500); 3 Oct 2008 22:38:57 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 48946 invoked by uid 500); 3 Oct 2008 22:38:57 -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 48935 invoked by uid 99); 3 Oct 2008 22:38:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Oct 2008 15:38:57 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of wayofdragon@gmail.com designates 209.85.198.224 as permitted sender) Received: from [209.85.198.224] (HELO rv-out-0506.google.com) (209.85.198.224) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Oct 2008 22:37:56 +0000 Received: by rv-out-0506.google.com with SMTP id f6so1730106rvb.5 for ; Fri, 03 Oct 2008 15:38:22 -0700 (PDT) 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:references; bh=lcDNnTxqA2BaK1a2h9S4uIES43PxIZqiywbcYu4qCPs=; b=l4ogrljDYSgthmeDmkf1ats7ugkITSL3yw5gl6+wpruC5+U7cuQj2ej+hI+pRLs9OF 2fYYbuNlbvaqeLL+FOpOiNE6dPfehK2YYFVe5oOXwkA/q7AB4u1dWfVuGp9GsGqyWIIk Q0pm8ioyfM7VgMs8JLgyCrn8drj5hFO4QbPPw= 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:references; b=ubtctOqTiaxDVQGp2kAoExL+3mnZQuypMCkoXxExPNEXdxD+FgW5VLYv9tCX12SqiQ 7YETLImhHzTTr3qpT2sSEERZpsLlB+eURfCAvi0VS8as5QQbZ+WbwsBVr0ddNqPs1YM0 AvpzSrP1iKYsjWT1zgim5Gx1CcXlKvxvLcRak= Received: by 10.141.88.3 with SMTP id q3mr1023017rvl.94.1223073502023; Fri, 03 Oct 2008 15:38:22 -0700 (PDT) Received: by 10.141.197.13 with HTTP; Fri, 3 Oct 2008 15:38:21 -0700 (PDT) Message-ID: Date: Fri, 3 Oct 2008 18:38:21 -0400 From: "Paul Chan" To: java-user@lucene.apache.org Subject: Re: ClassCastException when writing to index writer In-Reply-To: <0FAD03BA-50FA-4397-84A6-B74268C9EA58@mikemccandless.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_14175_3559666.1223073502023" References: <8717EE55-F146-42DA-B55D-1CEC37F5BC37@mikemccandless.com> <9D0CE7F0-1AFA-4B40-9956-E677C64BC2CE@mikemccandless.com> <0FAD03BA-50FA-4397-84A6-B74268C9EA58@mikemccandless.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_14175_3559666.1223073502023 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I am using Sun's JRE 1.6.0_02 on Windows XP Actually...are you sure it would work? java.util.Vector has the following clone() method: public Object *clone*() { } I didn't think you can cast a base class (Vector) to its derived class (SegmentInfos) in Java? On Fri, Oct 3, 2008 at 6:16 PM, Michael McCandless < lucene@mikemccandless.com> wrote: > > That's Sun's JRE? That should be fine, unless there's something seriously > wrong with it's java.util.Vector implementation. > > But, this is an exceptionally strange exception. Maybe try a different > version of the JRE? > > Any odd JARs on your CLASSPATH? > > What hardware/OS? > > > Mike > > Paul Chan wrote: > > I am using Java 1.6.0_02. Is this a problem? >> >> On Fri, Oct 3, 2008 at 5:35 PM, Michael McCandless < >> lucene@mikemccandless.com> wrote: >> >> >>> Which Java environment are you running? >>> >>> super.clone() from SegmentInfos should produce a new SegmentInfos object. >>> >>> It seems like in your case it's somehow producing a Vector instead? >>> >>> Mike >>> >>> >>> Paul Chan wrote: >>> >>> Hi Mike, >>> >>>> >>>> I am actually using the Compass Search Engine which in turn makes use of >>>> Lucene. They are doing the following in their code: >>>> >>>> IndexWriter indexWriter = new IndexWriter(dir, autoCommit, analyzer, >>>> create, deletionPolicy); >>>> >>>> where autoCommit = false. >>>> >>>> In turn, Lucene will do the following: >>>> >>>> public class IndexWriter { >>>> >>>> public IndexWriter(Directory d, boolean autoCommit, Analyzer a, >>>> boolean create, IndexDeletionPolicy deletionPolicy) >>>> throws CorruptIndexException, LockObtainFailedException, IOException >>>> { >>>> init(d, a, create, false, deletionPolicy, autoCommit); >>>> } >>>> >>>> private void init(Directory d, Analyzer a, final boolean create, >>>> boolean closeDir, IndexDeletionPolicy deletionPolicy, >>>> boolean autoCommit) >>>> { >>>> ... >>>> .. >>>> if (!autoCommit) { >>>> rollbackSegmentInfos = (SegmentInfos) segmentInfos.clone(); >>>> } >>>> } >>>> } >>>> >>>> which calls the clone() method that causes the exception because >>>> autoCommit >>>> = false. >>>> >>>> On Fri, Oct 3, 2008 at 4:54 PM, Michael McCandless < >>>> lucene@mikemccandless.com> wrote: >>>> >>>> >>>> Can you describe what led up to this exception? Ie, what calls you >>>>> made >>>>> to >>>>> Lucene before this. >>>>> >>>>> Mike >>>>> >>>>> >>>>> Paul Chan wrote: >>>>> >>>>> I think I know what the problem is looking at the code: >>>>> >>>>> >>>>>> In SegmentInfos.java (line 321): >>>>>> >>>>>> class SegmentInfos extends Vector >>>>>> { >>>>>> public Object clone() { >>>>>> SegmentInfos sis = (SegmentInfos) super.clone(); >>>>>> for(int i=0;i>>>>> sis.setElementAt(((SegmentInfo) sis.elementAt(i)).clone(), i); >>>>>> } >>>>>> return sis; >>>>>> } >>>>>> } >>>>>> >>>>>> We see that it is trying to cast a Vector into SegmentInfos which >>>>>> explains >>>>>> the ClassCastException. This is definitely a bug. >>>>>> >>>>>> >>>>>> On Fri, Oct 3, 2008 at 3:40 PM, Paul Chan >>>>>> wrote: >>>>>> >>>>>> Hi, >>>>>> >>>>>> >>>>>>> I am using lucene 2.3.2 and I encounter the following exception when >>>>>>> I >>>>>>> try >>>>>>> to insert a object into the index. >>>>>>> >>>>>>> Caused by: java.lang.ClassCastException: java.util.Vector cannot be >>>>>>> cast >>>>>>> to >>>>>>> org.apache.lucene.index.SegmentInfos >>>>>>> at org.apache.lucene.index.SegmentInfos.clone(SegmentInfos.java:321) >>>>>>> at org.apache.lucene.index.IndexWriter.init(IndexWriter.java:715) >>>>>>> at org.apache.lucene.index.IndexWriter.(IndexWriter.java:666) >>>>>>> >>>>>>> Has Anyone seen this problem before? What seems to be the problem? >>>>>>> >>>>>>> Thanks! >>>>>>> >>>>>>> >>>>>>> >>>>>>> --------------------------------------------------------------------- >>>>> 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 >>> >>> >>> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: java-user-help@lucene.apache.org > > ------=_Part_14175_3559666.1223073502023--