I am getting a "class cast exception" when I invoke the getter on a cmr-field. I am using JBuilder 6 and Web Logic Server 6.1
The cmr-field represents a unidirectional one-to-many relation between two entities. I have checked the XML generated by JBuilder and it is very correct. The getter is defined to return a collection.
The WebLogic EJBC compiler generates source code for a class that has this definition:
public final class Vsdescendentaccdata_WebLogic_CMP_RDBMS_viewacclabunit_Set implements RDBMSSet, Set, Serializable
I have tried assigning the value returned by the getter to a variable of type Set (my own implementation), to a avriable of type collection and to a variable of type vector. In all cases I get the class cast excpetion.
Can anyone suggest some things I may try or that I may look for. I have been working with BEA tech support, but that is going nowhere very slowly.
Just want to add on emore piece of information: the two entity beans and the generated class are all in a single jar file
Beep - not enough information error.
How about posting the relevant code...
How are you doing your casting?
Sorry. I didn't want to innundate, but believe me, I'd be happy to post the whole thing!
Here is the code. teh entity adBean contains the cmr-field Viewacclabunit, and the getter is referenced here. I have alternatly tried both the lines of code you see here, as well as creating my own implementation of the Set interface. All produce the same exception.
What is the correct way to cast the return value?
Thanx in advance for your help.
public void loadAccLabUnit(Vsdescendentaccdata adBean)
aluList = (ArrayList) adBean.getViewacclabunit();
aluListV = (Vector) adBean.getViewacclabunit();
Ok we're almost there now. I need to see the definition of adBean.getViewacclabunit(). I'll assume it is something like this:
public Collection getViewacclabunit();
Question for you, why are you trying to do those funny casts? You may find there are methods available to transform a Collection to an ArrayList, but I don't think casting works. Maybe I'm just not understanding your aim.
What's wrong with just doing it like this:
Collection aluCollection = adBean.getViewacclabunit();
Iterator it = aluCollection.iterator();
Viewacclabunit aluBean = (Viewacclabunit )it.next();
I hope that helps...