I have generally found that a ClassCastException (usually nested
three-layers deep in ominous sounding Orion exceptions) usually
indicates a wrong bean (or class) specified in the deployment
descriptor.

For instance, I was tearing my hair out over a ClassCastException I was
getting every time I tried to add an object to a collection which was a
EJB2.0 CMR field.  Turns out the problem was a cut-and-paste error when
I was creating the <relationship> in the deployment descriptor - the
<role-source> was a different bean than what I wanted (and specified in
the java code).  Totally obvious now - but at the time, I was looking at
the descriptor, and it "looked right" because all the elements were in
the right place.

I should point out that this would have been caught with a more obvious
message if Orion omitted the <cmp-field> tag from <entity> for CMR
fields, like the spec says it should :-)

Jeff

>-----Original Message-----
>From: Dag Rende [mailto:[EMAIL PROTECTED]]
>Sent: Friday, December 08, 2000 6:20 AM
>To: Orion-Interest
>Subject: Has anyone ever solved the ClassCastException problem?
>
>
>Hi!
>
>I have got the infamous ClassCastException problem when casting a home
>interface got from a context lookup. 
>
>I have seen many mails about this problem on this list, with 
>good advice and
>hints. But no one saying that it works.
>
>My code is the orion-primer example 
>(http://www.jollem.com/orion-primer/)
>that works inside one 
>machine but fails between two machines. The
>orion-primer is a ear with a web application that uses a simple EJB.
>
>The code fails in the narrow method below:
>
>...
>Context context = new InitialContext();
>Object boundObject = context.lookup("Hello");
>HelloHome helloHome = (HelloHome) 
>      PortableRemoteObject.narrow(boundObject, HelloHome.class);
>...
>
>The EJB works - I can call it using reflection. This proves 
>that I have not
>made any other mistake. I think this may be a classloader 
>problem in the
>class produced by the orion RMIInitialContextFactory.
>
>The code above works fine inside a java application.
>
>Regards,
>Dag Rende
>
>
>

Reply via email to