[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Objects versus proxies
On Thu, 06 Jul 2000, Charles Benett wrote:
> Hi!
>
> I'm getting a ClassCastException which doesn't make sense. Basically I
> have one database object which creates database objects of two other
> classes and then passes on of these to the other as a parameter of a
> method. The method call throws a ClassCastException referencing the
> Proxy for the parameter.
>
> OK. I have an object, dbObj1, with a default constructor and a method.
> The client app calls createObject(dbObj1) and then the method.
> Method is like this:
> blah, blah
> try {
> Interface2 varDbObj2 = (Interface2)
> database().createObject(class_DbObj2);
> varDbObj2.someMethod_update(); // no params
>
> Interface3 varDbObj3 = (Interface3)
> database().createObject(class_DbObj3);
> varDbObj3.init_update(String, String); // so the strings become
> persistent members of the dbObj3
>
> varDbObj2.add_update(varDbObj3); // throws UnexpectedException
> }
>
> The UnexpectedException is: ClassCastException class_DbObj3_Proxy
> at class_DbObj2_Proxy.add_update
> at class_DbObj1.Method
>
> The the add method is:
> public void add_update(Interface3 anObj) {
> someCollection.add(obj);
> // other stuff
> }
>
> But class_DbObj3, varDbObj3 and classDbObj3_Proxy all implement
> Interface 3, so why do I get a class cast exception?
Hmmm.. so far I don't see the problem. Can you please send the full stack traces
(with line numbers, if possible) from the client _and_ the server plus the
source code of the generated proxy? (-ks tells opp to keep sources)
BTW: your type names are somewhat confusing. Why don't you just follow the
naming conventions of the samples and the tutorial? They help to produce
readable and maintainable code and help other (ozone) programmers to
understand what you have done.
Falko
--
______________________________________________________________________
Falko Braeutigam mailto:falko@softwarebuero.de
softwarebuero m&b (SMB) http://www.softwarebuero.de