ClassCastException when writing to index writer

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

ClassCastException when writing to index writer

Paul Chan-2
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.<init>(IndexWriter.java:666)

Has Anyone seen this problem before?  What seems to be the problem?

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: ClassCastException when writing to index writer

Paul Chan-2
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.size();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 <[hidden email]> 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.<init>(IndexWriter.java:666)
>
> Has Anyone seen this problem before?  What seems to be the problem?
>
> Thanks!
>
Reply | Threaded
Open this post in threaded view
|

Re: ClassCastException when writing to index writer

Michael McCandless-2

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.size();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 <[hidden email]>  
> 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.<init>(IndexWriter.java:666)
>>
>> Has Anyone seen this problem before?  What seems to be the problem?
>>
>> Thanks!
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: ClassCastException when writing to index writer

Paul Chan-2
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 <
[hidden email]> 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.size();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 <[hidden email]> 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.<init>(IndexWriter.java:666)
>>>
>>> Has Anyone seen this problem before?  What seems to be the problem?
>>>
>>> Thanks!
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: ClassCastException when writing to index writer

Michael McCandless-2

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 <
> [hidden email]> 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.size();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 <[hidden email]>  
>>> 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.<init>(IndexWriter.java:666)
>>>>
>>>> Has Anyone seen this problem before?  What seems to be the problem?
>>>>
>>>> Thanks!
>>>>
>>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: ClassCastException when writing to index writer

Paul Chan-2
I am using Java 1.6.0_02.  Is this a problem?

On Fri, Oct 3, 2008 at 5:35 PM, Michael McCandless <
[hidden email]> 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 <
>> [hidden email]> 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.size();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 <[hidden email]>
>>>> 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.<init>(IndexWriter.java:666)
>>>>>
>>>>> Has Anyone seen this problem before?  What seems to be the problem?
>>>>>
>>>>> Thanks!
>>>>>
>>>>>
>>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: ClassCastException when writing to index writer

Michael McCandless-2

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 <
> [hidden email]> 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 <
>>> [hidden email]> 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.size();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 <[hidden email]>
>>>>> 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.<init>(IndexWriter.java:
>>>>>> 666)
>>>>>>
>>>>>> Has Anyone seen this problem before?  What seems to be the  
>>>>>> problem?
>>>>>>
>>>>>> Thanks!
>>>>>>
>>>>>>
>>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden email]
>>>> For additional commands, e-mail: [hidden email]
>>>>
>>>>
>>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: ClassCastException when writing to index writer

Paul Chan-2
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 <http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html>
*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 <
[hidden email]> 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 <
>> [hidden email]> 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 <
>>>> [hidden email]> 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.size();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 <[hidden email]>
>>>>>> 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.<init>(IndexWriter.java:666)
>>>>>>>
>>>>>>> Has Anyone seen this problem before?  What seems to be the problem?
>>>>>>>
>>>>>>> Thanks!
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: [hidden email]
>>>>> For additional commands, e-mail: [hidden email]
>>>>>
>>>>>
>>>>>
>>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: ClassCastException when writing to index writer

hossman
In reply to this post by Paul Chan-2

:        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 Cloneable interface...

> By convention, the returned object should be obtained by calling
> super.clone. If a class and all of its superclasses (except Object) obey
> this convention, it will be the case that x.clone().getClass() ==
> x.getClass()
        ...
> The method clone for class Object performs a specific cloning operation.
> First, if the class of this object does not implement the interface
> Cloneable, then a CloneNotSupportedException is thrown. Note that all
> arrays are considered to implement the interface Cloneable. Otherwise,
> this method creates a new instance of the class of this object and
> initializes all its fields with exactly the contents of the ...

I'm really not sure how you could be getting that ClassCastException
unless there's a really horrific bug in the JRE you are using.

You'll see this in just about every (non-trivial) use of super.clone() ...

http://www.google.com/codesearch?q=super.clone%28%29+lang%3Ajava



-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: ClassCastException when writing to index writer

Edwin Lee-4
In reply to this post by Paul Chan-2
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 fields/elements to
get a deep copy.

May sound counter-intuitive, but the delegated call to Vector.clone actually
does return an instance of SegmentInfos. This is because when the clone is
eventually delegated to Object.clone, it is a native call which does a "native
copying" of the instance (in this case, a SegmentInfos instance).

i have tried running a test, and SegmentInfos.clone does work for me. You may
want to try running the following programme using the same classpath settings
that you used with the actual programme:

package org.apache.lucene.index;

public class Test {
   
    public static final void main(String[] args) {
       
        SegmentInfos sis = new SegmentInfos();

        SegmentInfos sis2 = (SegmentInfos) sis.clone();

        System.out.println("done");
    }
}



HTH,
Edwin



--- Paul Chan <[hidden email]> wrote:

> 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 <http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html>
> *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 <
> [hidden email]> 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 <
> >> [hidden email]> 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 <
> >>>> [hidden email]> 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.size();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 <[hidden email]>
> >>>>>> 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.<init>(IndexWriter.java:666)
> >>>>>>>
> >>>>>>> Has Anyone seen this problem before?  What seems to be the problem?
> >>>>>>>
> >>>>>>> Thanks!
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> ---------------------------------------------------------------------
> >>>>> To unsubscribe, e-mail: [hidden email]
> >>>>> For additional commands, e-mail: [hidden email]
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: [hidden email]
> >>> For additional commands, e-mail: [hidden email]
> >>>
> >>>
> >>>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>



      New Email addresses available on Yahoo!
Get the Email name you&#39;ve always wanted on the new @ymail and @rocketmail.
Hurry before someone else does!
http://mail.promotions.yahoo.com/newdomains/sg/


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: ClassCastException when writing to index writer

Edwin Lee-4
In reply to this post by hossman
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 <[hidden email]> wrote:

>
> :        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.
>
> I'm really not sure how you could be getting that ClassCastException
> unless there's a really horrific bug in the JRE you are using.
>
> You'll see this in just about every (non-trivial) use of super.clone() ...



      Yahoo! Toolbar is now powered with Search Assist.Download it now!
http://sg.toolbar.yahoo.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: ClassCastException when writing to index writer

Paul Chan-2
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 = (SegmentInfos) sis.clone();

   - Interestingly, I tried to create a dummy test class which mimics
   SegmentInfos as follows and it works!:

public class TestVector extends Vector
{
   public TestVector clone()
   {
      TestVector cl = (TestVector)super.clone();
      return cl;
   }
}

         TestVector vector = new TestVector();
         TestVector vClone = (TestVector)vector.clone();

   - This tells me that perhaps there is something wrong with the lucene
   package that I have downloaded (some sort of incompatibility?).  I will try
   to recompile the lucene package in my own environment and see if I can fix
   the problem.


On Sat, Oct 4, 2008 at 2:21 AM, Edwin Lee <[hidden email]> wrote:

> 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 <[hidden email]> wrote:
>
> >
> > :        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.
> >
> > I'm really not sure how you could be getting that ClassCastException
> > unless there's a really horrific bug in the JRE you are using.
> >
> > You'll see this in just about every (non-trivial) use of super.clone()
> ...
>
>
>
>       Yahoo! Toolbar is now powered with Search Assist.Download it now!
> http://sg.toolbar.yahoo.com/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: ClassCastException when writing to index writer

Paul Chan-2
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 all.  I don't really know what to do at this moment.  Does anyone have
any insight?

On Sun, Oct 5, 2008 at 10:45 PM, Paul Chan <[hidden email]> wrote:

> 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 = (SegmentInfos) sis.clone();
>
>    - Interestingly, I tried to create a dummy test class which mimics
>    SegmentInfos as follows and it works!:
>
> public class TestVector extends Vector
> {
>    public TestVector clone()
>    {
>       TestVector cl = (TestVector)super.clone();
>       return cl;
>    }
> }
>
>          TestVector vector = new TestVector();
>          TestVector vClone = (TestVector)vector.clone();
>
>    - This tells me that perhaps there is something wrong with the lucene
>    package that I have downloaded (some sort of incompatibility?).  I will try
>    to recompile the lucene package in my own environment and see if I can fix
>    the problem.
>
>
> On Sat, Oct 4, 2008 at 2:21 AM, Edwin Lee <[hidden email]>wrote:
>
>> 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 <[hidden email]> wrote:
>>
>> >
>> > :        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.
>> >
>> > I'm really not sure how you could be getting that ClassCastException
>> > unless there's a really horrific bug in the JRE you are using.
>> >
>> > You'll see this in just about every (non-trivial) use of super.clone()
>> ...
>>
>>
>>
>>       Yahoo! Toolbar is now powered with Search Assist.Download it now!
>> http://sg.toolbar.yahoo.com/
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: ClassCastException when writing to index writer

Edwin Lee-4
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 <[hidden email]> wrote:

> 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 all.  I don't really know what to do at this moment.  Does anyone have
> any insight?
>
> On Sun, Oct 5, 2008 at 10:45 PM, Paul Chan <[hidden email]> wrote:
>
> > 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 = (SegmentInfos) sis.clone();
> >
> >    - Interestingly, I tried to create a dummy test class which mimics
> >    SegmentInfos as follows and it works!:
> >
> > public class TestVector extends Vector
> > {
> >    public TestVector clone()
> >    {
> >       TestVector cl = (TestVector)super.clone();
> >       return cl;
> >    }
> > }
> >
> >          TestVector vector = new TestVector();
> >          TestVector vClone = (TestVector)vector.clone();
> >
> >    - This tells me that perhaps there is something wrong with the lucene
> >    package that I have downloaded (some sort of incompatibility?).  I will
> try
> >    to recompile the lucene package in my own environment and see if I can
> fix
> >    the problem.
> >
> >
> > On Sat, Oct 4, 2008 at 2:21 AM, Edwin Lee <[hidden email]>wrote:
> >
> >> 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 <[hidden email]> wrote:
> >>
> >> >
> >> > :        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.
> >> >
> >> > I'm really not sure how you could be getting that ClassCastException
> >> > unless there's a really horrific bug in the JRE you are using.
> >> >
> >> > You'll see this in just about every (non-trivial) use of super.clone()
> >> ...
> >>
> >>
> >>
> >>       Yahoo! Toolbar is now powered with Search Assist.Download it now!
> >> http://sg.toolbar.yahoo.com/
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]
> >> For additional commands, e-mail: [hidden email]
> >>
> >>
> >
>



      Get your preferred Email name!
Now you can @ymail.com and @rocketmail.com
http://mail.promotions.yahoo.com/newdomains/sg/


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: ClassCastException when writing to index writer

Paul Chan-2
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 did some more investigation and I found the following:

final class SegmentInfos extends Vector
{
   public Object clone() {
      Object a = super.clone(); --> code that I added to do some debug
     SegmentInfos sis = (SegmentInfos) a;
     ...
   }
}

When super.clone() returns, it actually returns a Vector object instead of a
SegmentInfos object against my expectation so that explains why the
ClassCastException occurs.  On the other hand, when I run my TestVector
class:

final class TestVector extends Vector
{
   public Object clone() {
      Object a = super.clone(); --> code that I added to do some debug
      TestVector sis = (TestVector) a;
     ...
   }
}

When super.clone() returns, it returns TestVector!

This tells me that there is something wrong with Lucene build file that
causes this problem, but I have no idea what it could be.  In Lucene's
common-build.xml, I changed the 1.4 properties to 1.6 propreties but still
to no avail.


On Mon, Oct 6, 2008 at 12:04 PM, Edwin Lee <[hidden email]>wrote:

> 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 <[hidden email]> wrote:
>
> > 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 all.  I don't really know what to do at this moment.  Does anyone have
> > any insight?
> >
> > On Sun, Oct 5, 2008 at 10:45 PM, Paul Chan <[hidden email]>
> wrote:
> >
> > > 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 = (SegmentInfos) sis.clone();
> > >
> > >    - Interestingly, I tried to create a dummy test class which mimics
> > >    SegmentInfos as follows and it works!:
> > >
> > > public class TestVector extends Vector
> > > {
> > >    public TestVector clone()
> > >    {
> > >       TestVector cl = (TestVector)super.clone();
> > >       return cl;
> > >    }
> > > }
> > >
> > >          TestVector vector = new TestVector();
> > >          TestVector vClone = (TestVector)vector.clone();
> > >
> > >    - This tells me that perhaps there is something wrong with the
> lucene
> > >    package that I have downloaded (some sort of incompatibility?).  I
> will
> > try
> > >    to recompile the lucene package in my own environment and see if I
> can
> > fix
> > >    the problem.
> > >
> > >
> > > On Sat, Oct 4, 2008 at 2:21 AM, Edwin Lee <[hidden email]
> >wrote:
> > >
> > >> 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 <[hidden email]> wrote:
> > >>
> > >> >
> > >> > :        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.
> > >> >
> > >> > I'm really not sure how you could be getting that ClassCastException
> > >> > unless there's a really horrific bug in the JRE you are using.
> > >> >
> > >> > You'll see this in just about every (non-trivial) use of
> super.clone()
> > >> ...
> > >>
> > >>
> > >>
> > >>       Yahoo! Toolbar is now powered with Search Assist.Download it
> now!
> > >> http://sg.toolbar.yahoo.com/
> > >>
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: [hidden email]
> > >> For additional commands, e-mail: [hidden email]
> > >>
> > >>
> > >
> >
>
>
>
>       Get your preferred Email name!
> Now you can @ymail.com and @rocketmail.com
> http://mail.promotions.yahoo.com/newdomains/sg/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: ClassCastException when writing to index writer

Paul Chan-2
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 see if I have done something wrong on my end.

Thanks again for everyone's help!

On Mon, Oct 6, 2008 at 12:26 PM, Paul Chan <[hidden email]> wrote:

> 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 did some more investigation and I found the following:
>
> final class SegmentInfos extends Vector
> {
>    public Object clone() {
>       Object a = super.clone(); --> code that I added to do some debug
>      SegmentInfos sis = (SegmentInfos) a;
>      ...
>    }
> }
>
> When super.clone() returns, it actually returns a Vector object instead of
> a SegmentInfos object against my expectation so that explains why the
> ClassCastException occurs.  On the other hand, when I run my TestVector
> class:
>
> final class TestVector extends Vector
> {
>    public Object clone() {
>       Object a = super.clone(); --> code that I added to do some debug
>       TestVector sis = (TestVector) a;
>      ...
>    }
> }
>
> When super.clone() returns, it returns TestVector!
>
> This tells me that there is something wrong with Lucene build file that
> causes this problem, but I have no idea what it could be.  In Lucene's
> common-build.xml, I changed the 1.4 properties to 1.6 propreties but still
> to no avail.
>
>
>
> On Mon, Oct 6, 2008 at 12:04 PM, Edwin Lee <[hidden email]>wrote:
>
>> 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 <[hidden email]> wrote:
>>
>> > 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 all.  I don't really know what to do at this moment.  Does anyone
>> have
>> > any insight?
>> >
>> > On Sun, Oct 5, 2008 at 10:45 PM, Paul Chan <[hidden email]>
>> wrote:
>> >
>> > > 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 = (SegmentInfos) sis.clone();
>> > >
>> > >    - Interestingly, I tried to create a dummy test class which mimics
>> > >    SegmentInfos as follows and it works!:
>> > >
>> > > public class TestVector extends Vector
>> > > {
>> > >    public TestVector clone()
>> > >    {
>> > >       TestVector cl = (TestVector)super.clone();
>> > >       return cl;
>> > >    }
>> > > }
>> > >
>> > >          TestVector vector = new TestVector();
>> > >          TestVector vClone = (TestVector)vector.clone();
>> > >
>> > >    - This tells me that perhaps there is something wrong with the
>> lucene
>> > >    package that I have downloaded (some sort of incompatibility?).  I
>> will
>> > try
>> > >    to recompile the lucene package in my own environment and see if I
>> can
>> > fix
>> > >    the problem.
>> > >
>> > >
>> > > On Sat, Oct 4, 2008 at 2:21 AM, Edwin Lee <[hidden email]
>> >wrote:
>> > >
>> > >> 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 <[hidden email]> wrote:
>> > >>
>> > >> >
>> > >> > :        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.
>> > >> >
>> > >> > I'm really not sure how you could be getting that
>> ClassCastException
>> > >> > unless there's a really horrific bug in the JRE you are using.
>> > >> >
>> > >> > You'll see this in just about every (non-trivial) use of
>> super.clone()
>> > >> ...
>> > >>
>> > >>
>> > >>
>> > >>       Yahoo! Toolbar is now powered with Search Assist.Download it
>> now!
>> > >> http://sg.toolbar.yahoo.com/
>> > >>
>> > >>
>> > >> ---------------------------------------------------------------------
>> > >> To unsubscribe, e-mail: [hidden email]
>> > >> For additional commands, e-mail: [hidden email]
>> > >>
>> > >>
>> > >
>> >
>>
>>
>>
>>       Get your preferred Email name!
>> Now you can @ymail.com and @rocketmail.com
>> http://mail.promotions.yahoo.com/newdomains/sg/
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: ClassCastException when writing to index writer

Edwin Lee-4
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 <[hidden email]> wrote:

> 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 see if I have done something wrong on my end.
>
> Thanks again for everyone's help!
>
> On Mon, Oct 6, 2008 at 12:26 PM, Paul Chan <[hidden email]> wrote:
>
> > 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 did some more investigation and I found the following:
> >
> > final class SegmentInfos extends Vector
> > {
> >    public Object clone() {
> >       Object a = super.clone(); --> code that I added to do some debug
> >      SegmentInfos sis = (SegmentInfos) a;
> >      ...
> >    }
> > }
> >
> > When super.clone() returns, it actually returns a Vector object instead of
> > a SegmentInfos object against my expectation so that explains why the
> > ClassCastException occurs.  On the other hand, when I run my TestVector
> > class:
> >
> > final class TestVector extends Vector
> > {
> >    public Object clone() {
> >       Object a = super.clone(); --> code that I added to do some debug
> >       TestVector sis = (TestVector) a;
> >      ...
> >    }
> > }
> >
> > When super.clone() returns, it returns TestVector!
> >
> > This tells me that there is something wrong with Lucene build file that
> > causes this problem, but I have no idea what it could be.  In Lucene's
> > common-build.xml, I changed the 1.4 properties to 1.6 propreties but still
> > to no avail.
> >
> >
> >
> > On Mon, Oct 6, 2008 at 12:04 PM, Edwin Lee
> <[hidden email]>wrote:
> >
> >> 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 <[hidden email]> wrote:
> >>
> >> > 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 all.  I don't really know what to do at this moment.  Does anyone
> >> have
> >> > any insight?
> >> >
> >> > On Sun, Oct 5, 2008 at 10:45 PM, Paul Chan <[hidden email]>
> >> wrote:
> >> >
> >> > > 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 = (SegmentInfos) sis.clone();
> >> > >
> >> > >    - Interestingly, I tried to create a dummy test class which mimics
> >> > >    SegmentInfos as follows and it works!:
> >> > >
> >> > > public class TestVector extends Vector
> >> > > {
> >> > >    public TestVector clone()
> >> > >    {
> >> > >       TestVector cl = (TestVector)super.clone();
> >> > >       return cl;
> >> > >    }
> >> > > }
> >> > >
> >> > >          TestVector vector = new TestVector();
> >> > >          TestVector vClone = (TestVector)vector.clone();
> >> > >
> >> > >    - This tells me that perhaps there is something wrong with the
> >> lucene
> >> > >    package that I have downloaded (some sort of incompatibility?).  I
> >> will
> >> > try
> >> > >    to recompile the lucene package in my own environment and see if I
> >> can
> >> > fix
> >> > >    the problem.
> >> > >
> >> > >
> >> > > On Sat, Oct 4, 2008 at 2:21 AM, Edwin Lee <[hidden email]
> >> >wrote:
> >> > >
> >> > >> 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 <[hidden email]> wrote:
> >> > >>
> >> > >> >
> >> > >> > :        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.
> >> > >> >
> >> > >> > I'm really not sure how you could be getting that
> >> ClassCastException
> >> > >> > unless there's a really horrific bug in the JRE you are using.
> >> > >> >
> >> > >> > You'll see this in just about every (non-trivial) use of
> >> super.clone()
> >> > >> ...
> >> > >>
> >> > >>
> >> > >>
> >> > >>       Yahoo! Toolbar is now powered with Search Assist.Download it
> >> now!
> >> > >> http://sg.toolbar.yahoo.com/
> >> > >>
> >> > >>
> >> > >> ---------------------------------------------------------------------
> >> > >> To unsubscribe, e-mail: [hidden email]
> >> > >> For additional commands, e-mail: [hidden email]
> >> > >>
> >> > >>
> >> > >
> >> >
> >>
> >>
> >>
> >>       Get your preferred Email name!
> >> Now you can @ymail.com and @rocketmail.com
> >> http://mail.promotions.yahoo.com/newdomains/sg/
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]
> >> For additional commands, e-mail: [hidden email]
> >>
> >>
> >
>



      New Email names for you!
Get the Email name you&#39;ve always wanted on the new @ymail and @rocketmail.
Hurry before someone else does!
http://mail.promotions.yahoo.com/newdomains/sg/


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: ClassCastException when writing to index writer

Paul Chan-2
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 they override Vector either :p

Cheers,

Paul

On Tue, Oct 7, 2008 at 12:34 AM, Edwin Lee <[hidden email]>wrote:

> 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 <[hidden email]> wrote:
>
> > 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 see if I have done something wrong on my end.
> >
> > Thanks again for everyone's help!
> >
> > On Mon, Oct 6, 2008 at 12:26 PM, Paul Chan <[hidden email]>
> wrote:
> >
> > > 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 did some more investigation and I found the following:
> > >
> > > final class SegmentInfos extends Vector
> > > {
> > >    public Object clone() {
> > >       Object a = super.clone(); --> code that I added to do some debug
> > >      SegmentInfos sis = (SegmentInfos) a;
> > >      ...
> > >    }
> > > }
> > >
> > > When super.clone() returns, it actually returns a Vector object instead
> of
> > > a SegmentInfos object against my expectation so that explains why the
> > > ClassCastException occurs.  On the other hand, when I run my TestVector
> > > class:
> > >
> > > final class TestVector extends Vector
> > > {
> > >    public Object clone() {
> > >       Object a = super.clone(); --> code that I added to do some debug
> > >       TestVector sis = (TestVector) a;
> > >      ...
> > >    }
> > > }
> > >
> > > When super.clone() returns, it returns TestVector!
> > >
> > > This tells me that there is something wrong with Lucene build file that
> > > causes this problem, but I have no idea what it could be.  In Lucene's
> > > common-build.xml, I changed the 1.4 properties to 1.6 propreties but
> still
> > > to no avail.
> > >
> > >
> > >
> > > On Mon, Oct 6, 2008 at 12:04 PM, Edwin Lee
> > <[hidden email]>wrote:
> > >
> > >> 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 <[hidden email]> wrote:
> > >>
> > >> > 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 all.  I don't really know what to do at this moment.  Does anyone
> > >> have
> > >> > any insight?
> > >> >
> > >> > On Sun, Oct 5, 2008 at 10:45 PM, Paul Chan <[hidden email]>
> > >> wrote:
> > >> >
> > >> > > 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 = (SegmentInfos) sis.clone();
> > >> > >
> > >> > >    - Interestingly, I tried to create a dummy test class which
> mimics
> > >> > >    SegmentInfos as follows and it works!:
> > >> > >
> > >> > > public class TestVector extends Vector
> > >> > > {
> > >> > >    public TestVector clone()
> > >> > >    {
> > >> > >       TestVector cl = (TestVector)super.clone();
> > >> > >       return cl;
> > >> > >    }
> > >> > > }
> > >> > >
> > >> > >          TestVector vector = new TestVector();
> > >> > >          TestVector vClone = (TestVector)vector.clone();
> > >> > >
> > >> > >    - This tells me that perhaps there is something wrong with the
> > >> lucene
> > >> > >    package that I have downloaded (some sort of incompatibility?).
>  I
> > >> will
> > >> > try
> > >> > >    to recompile the lucene package in my own environment and see
> if I
> > >> can
> > >> > fix
> > >> > >    the problem.
> > >> > >
> > >> > >
> > >> > > On Sat, Oct 4, 2008 at 2:21 AM, Edwin Lee <
> [hidden email]
> > >> >wrote:
> > >> > >
> > >> > >> 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 <[hidden email]> wrote:
> > >> > >>
> > >> > >> >
> > >> > >> > :        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.
> > >> > >> >
> > >> > >> > I'm really not sure how you could be getting that
> > >> ClassCastException
> > >> > >> > unless there's a really horrific bug in the JRE you are using.
> > >> > >> >
> > >> > >> > You'll see this in just about every (non-trivial) use of
> > >> super.clone()
> > >> > >> ...
> > >> > >>
> > >> > >>
> > >> > >>
> > >> > >>       Yahoo! Toolbar is now powered with Search Assist.Download
> it
> > >> now!
> > >> > >> http://sg.toolbar.yahoo.com/
> > >> > >>
> > >> > >>
> > >> > >>
> ---------------------------------------------------------------------
> > >> > >> To unsubscribe, e-mail: [hidden email]
> > >> > >> For additional commands, e-mail:
> [hidden email]
> > >> > >>
> > >> > >>
> > >> > >
> > >> >
> > >>
> > >>
> > >>
> > >>       Get your preferred Email name!
> > >> Now you can @ymail.com and @rocketmail.com
> > >> http://mail.promotions.yahoo.com/newdomains/sg/
> > >>
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: [hidden email]
> > >> For additional commands, e-mail: [hidden email]
> > >>
> > >>
> > >
> >
>
>
>
>       New Email names for you!
> Get the Email name you've always wanted on the new @ymail and @rocketmail.
> Hurry before someone else does!
> http://mail.promotions.yahoo.com/newdomains/sg/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>