Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

classcastexception on portableremoteobject narrow

0 views
Skip to first unread message

Sandy Barletta

unread,
Mar 9, 2001, 4:32:45 PM3/9/01
to
I was successfully connecting to an EJB on my WebLogic server from a Java
IDL client using the iiop protocol, cosnaming initialcontextfactory. I'm at
a loss as to what is different now that is causing this to fail. I'm sure
it has something to do with how I'm generating the stubs and/or the
client/server classpath, but can't see what I'm doing wrong now. My steps
are as follows.

1) Create the EJB jar (call it jar1) using weblogic.ejbc
2) Run jar1 through weblogic.ejbc using -idl -iiop, creating jar2
3) Deploy jar2 in the java client's classpath

I get the initial context fine, but when I get to this line:
_home = (myHome)(PortableRemoteObject.narrow(ctx, myHome.class));

I get the following error:
java.lang.ClassCastException
at
com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemo
teObject.java:296)

Can anyone give me some assistance?

Thx!
Sandy Barletta


Sandy Barletta

unread,
Mar 19, 2001, 12:18:06 PM3/19/01
to
Ok, here's what's going on here. The problem happens when I use
com.sun.jndi.cosnaming.CNCtxFactory as my initial context factory. After the
lookup of the home interface, what I get back in my context object if I call
getClass().getName() is the following:
com.sun.jndi.cosnaming.CNCtx
The class cast exception occurs when I try to narrow this to my home
interface.

If I use weblogic.jndi.WLInitialContextFactory instead of
com.sun.jndi.cosnaming.CNCtxFactory, what I get back in my context object if
I call getClass().getName() is
com.sun.corba.se.internal.iiop.CDRInputStream$1 and the narrow succeeds.

What gives? Do I have to use the weblogic context factory? I was hoping to
avoid the need for weblogic packages on the client. Also, our whole reason
for using IIOP was to avoid compatibility problems between weblogic servers
running at different version levels. If I have to use the weblogic context
factory, and we have a weblogic client running at a different version from
the server, will there be problem?

Sandy Barletta


"Sandy Barletta" <sbar...@hotmail.com> wrote in message
news:3aa94c5f$1...@newsgroups.bea.com...

Andy Piper

unread,
Mar 23, 2001, 1:15:05 PM3/23/01
to
"Sandy Barletta" <sbar...@hotmail.com> writes:

> Ok, here's what's going on here. The problem happens when I use
> com.sun.jndi.cosnaming.CNCtxFactory as my initial context factory. After the
> lookup of the home interface, what I get back in my context object if I call
> getClass().getName() is the following:
> com.sun.jndi.cosnaming.CNCtx
> The class cast exception occurs when I try to narrow this to my home
> interface.

I don't think you should be doing this - you should be using lookup
since this context implements the javax.jndi.Context interface and is
not actually your object.

> If I use weblogic.jndi.WLInitialContextFactory instead of
> com.sun.jndi.cosnaming.CNCtxFactory, what I get back in my context object if
> I call getClass().getName() is
> com.sun.corba.se.internal.iiop.CDRInputStream$1 and the narrow succeeds.

So this is an RMI-IIOP representation of the remote JNDI
implementation. In the former case you are using the sun
implementation to map to CosNaming and then relying on WLS to map that
back to JNDI. This certainly works in silversword, so I would be
surprised if it is broken in 6.0

andy

0 new messages