Hello,
I tried to determine where the problem comes from and I found the
following thing :
In jdk 1.3, the method ArrayList.addAll(Collection c) is this :
public boolean addAll(Collection c) {
modCount++;
int numNew = c.size();
ensureCapacity(size + numNew);
Iterator e = c.iterator();
for (int i=0; i<numNew; i++)
elementData[size++] = e.next();
return numNew != 0;
}
And the call to RelationCollection class is made by e.next(), and gets
the right object from the lazy collection.
In jdk 1.4, the method ArrayList.addAll(Collection c) is this :
public boolean addAll(Collection c) {
Object[] a = c.toArray();
int numNew = a.length;
ensureCapacity(size + numNew); // Increments modCount
System.arraycopy(a, 0, elementData, size, numNew);
size += numNew;
return numNew != 0;
}
And the call to RelationCollection class is made by c.toArray();
public Object[] toArray() {
Object[] result = new Object[size()];
Iterator itor = iterator();
while ( itor.hasNext() ) {
result = (Object[])itor.next();
}
return result;
}
But on itor.next() we retrieve an element of the lazy collection, but
not a Object[] .
So I've got the class cast exception.
Is there something I can do ?
Sylvie.
___________________
CREDI RA
Sylvie Palluel
[EMAIL PROTECTED]
___________________
-----Message d'origine-----
De : SYLVIE PALLUEL [mailto:[EMAIL PROTECTED]
Envoy� : vendredi 14 novembre 2003 08:54
� : [EMAIL PROTECTED]
Objet : [castor-dev] org.exolab.castor.persist.RelationCollection and
ClassCastException with jdk1.4.2.01
Hello,
Since now I was using jdk 1.3.1. And I have no special problem.
Then I'm using jdk 1.4.2.01.
I have the class "profilMetier" which is a persistent class with
"listeHabilitation" as lazy attribut
/**
* Collection regroupant les r�f�rences aux habilitations rattach�es �
ce profil
* @field-type
fr.cnam.scapin.metier.donnees.agents.profils.Habilitation
* @lazy
* @many-key idProfil
*/
private java.util.Collection listeHabilitation;
public java.util.Collection getListeHabilitation() {
return listeHabilitation;
}
Somewhere in my code I try to do this :
ArrayList listeTriee = new ArrayList();
listeTriee.addAll(profilMetier.getListeHabilitation());
And then I have this error :
549512 [Thread-5] ERROR exception.ApplicationException - Message =
error.transaction.rollback - nestedException =
java.lang.ClassCastException java.lang.ClassCastException
at
org.exolab.castor.persist.RelationCollection.toArray(RelationCollection.
java:405)
at java.util.ArrayList.addAll(ArrayList.java:434)
at
fr.cnam.scapin.metier.impl.agents.ProfilBeanImpl.getBean(ProfilBeanImpl.
java:146)
at
fr.cnam.scapin.commun.ServeurDeBean.getBean(ServeurDeBean.java:89)
RelationCollection :
public Object[] toArray() {
Object[] result = new Object[size()];
Iterator itor = iterator();
while ( itor.hasNext() ) {
result = (Object[])itor.next(); <--- line 405
}
return result;
}
Do I need to update a library ? Or have I made a mistake ?
Thanks for your help.
Sylvie.
___________________
CREDI RA
Sylvie Palluel
[EMAIL PROTECTED]
___________________
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they are
addressed. If you have received this email in error please notify the
system manager.
This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
www.mimesweeper.com
**********************************************************************
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
www.mimesweeper.com
**********************************************************************
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev