WebLogic 6.1 SP 2
Solaris
Now the problem:
We have an EJB client that resides on a different machine then the server. The
client successfully gets the InitialContext from the server and completes a lookup
on the Context. The server returns a $Proxy1 class that implements the following
interfaces:
org.cas.mybean.MyBeanHome
javax.ejb.EJBHome
weblogic.ejb20.interfaces.RemoteHome
weblogic.rmi.internal.StubInfoIntf
The problem comes when I try to downcast the stub to type MyBeanHome. This is
where I get a ClassCastException. Here is the code that I am using to lookup
the bean and narrow it:
Properties props = new Properties();
props.put(Context.PROVIDER_URL, "t3://myremoteserver:7001");
props.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
Context ctx = new InitialContext(props);
Object ref = ctx.lookup("MyBeanHome");
MyBeanHome myBeanHome = (MyBeanHome) PortableRemoteObject.narrow(ref, MyBeanHome.class);
MyBean myBean = myBeanHome.create();
We get the following exception:
java.lang.ClassCastException
at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:296)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
at org.cas.mybean.MyBeanFT.setUp(MyBeanFT.java:97)
I did some testing and found that I can narrow the $Proxy1 stub that is returned
to an EJBHome interface but then I can not cast is to MyBeanHome.
I noticed that this was a problem that was supposedly fixed in SP2 but as you
can see I am using SP and I am still getting the problem. Here is the bug fix
that I am refering to:
060416 -
Fixed a problem where performing an EJB lookup in a tiered environment caused
a ClassCastException to be thrown when the EJB Home object was cast to its specific
type.
Thanks,
andy