Re: ClassCastException when writing to index writer

2008-10-06 Thread Paul Chan
Hi Edwin, Would love to pose the code, but I don't have the Terracotta source code at the moment as I only downloaded the binaries. But Terracotta is an open source project so you can checkout their code base ( http://www.terracotta.org/web/display/orgsite/DownloadCatalog). I have no idea how th

Re: ClassCastException when writing to index writer

2008-10-06 Thread Edwin Lee
Hi Paul, now i'm curious to know how the overriden java.util.Vector implements the clone method. Any chance of posting a snippet? ;) Cheers, Edwin --- Paul Chan <[EMAIL PROTECTED]> wrote: > Seems like I found the culprit to the problem. Because I am using > Terracotta to doing JVM clusteri

Re: ClassCastException when writing to index writer

2008-10-06 Thread Paul Chan
Seems like I found the culprit to the problem. Because I am using Terracotta to doing JVM clustering, it has overriden many classes of java.util.*. If I take out Terracotta from my configuration, then I don't get the ClassCastException problem any longer. I will talk to the Terracotta folks to s

Re: ClassCastException when writing to index writer

2008-10-06 Thread Paul Chan
Hi Edwin, Yes, I am running the TestVector against the same class path as my actual application. My class path contains the Lucene JAR files. This is very bizzard because my TestVector class extends Vector and it works, but for some reason SegmentInfos also extends Vector but it doesnt work. I d

Re: ClassCastException when writing to index writer

2008-10-06 Thread Edwin Lee
Hi Paul, When you say that your dummy TestVector class works, are you running it using the same classpaths that you used to run your actual application? Does it contain the Lucene JAR files? Regards, Edwin --- Paul Chan <[EMAIL PROTECTED]> wrote: > I have tried to recompile Lucene 2.3.2 und

Re: ClassCastException when writing to index writer

2008-10-05 Thread Paul Chan
I have tried to recompile Lucene 2.3.2 under my environment (SUN JDK 1.6) and it still doesn't work. I am beginning to think that maybe there is something wrong with lucene's build script. My TestVector class's clone() method works without a hitch, but SegmentInfos' clone() method doesnt work at

Re: ClassCastException when writing to index writer

2008-10-05 Thread Paul Chan
Thank you all for your input. However, this is what I have discovered so far: - I tried running the test that Edwin suggested and it failed for me in my environment (Lucene 2.3.2, Windows XP, SUN JDK 1.5 or 1.6) e.g. SegmentInfos sis = new SegmentInfos(); SegmentInfos sis2 = (Segment

Re: ClassCastException when writing to index writer

2008-10-03 Thread Edwin Lee
i think, very likely, you have another copy of java.util.Vector loaded, and this one tries to be too clever with its implementation of clone (instantiate a new Vector instance) instead of delegating to its super class (Object). HTH, Edwin --- Chris Hostetter <[EMAIL PROTECTED]> wrote: > > :

Re: ClassCastException when writing to index writer

2008-10-03 Thread Edwin Lee
Hi Paul, The clone() in SegmentInfos is correct. The best practice of clone is to delegate the clone to the super class (if you look at the source code for Vector, it too delegates to its super class, which is the Object) to create a shallow copy, and then do a cloning of each of its mutable field

Re: ClassCastException when writing to index writer

2008-10-03 Thread Chris Hostetter
:SegmentInfos sis = (SegmentInfos) super.clone(); : We see that it is trying to cast a Vector into SegmentInfos which explains : the ClassCastException. This is definitely a bug. That is in the correct and specified use of clone() ... note the javadocs for Object.clone() and the Clonea

Re: ClassCastException when writing to index writer

2008-10-03 Thread Paul Chan
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 clas

Re: ClassCastException when writing to index writer

2008-10-03 Thread Michael McCandless
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

Re: ClassCastException when writing to index writer

2008-10-03 Thread Paul Chan
I am using Java 1.6.0_02. Is this a problem? On Fri, Oct 3, 2008 at 5:35 PM, Michael McCandless < [EMAIL PROTECTED]> 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 produc

Re: ClassCastException when writing to index writer

2008-10-03 Thread Michael McCandless
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

Re: ClassCastException when writing to index writer

2008-10-03 Thread Paul Chan
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 foll

Re: ClassCastException when writing to index writer

2008-10-03 Thread Michael McCandless
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

Re: ClassCastException when writing to index writer

2008-10-03 Thread Paul Chan
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 wrote: > Hi, > > I am using lucene 2.3.2 and I encounter the follo

ClassCastException when writing to index writer

2008-10-03 Thread Paul Chan
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) a