Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ClassCastException when performing PortableRemoteObject.narrow

Status
Not open for further replies.

cuinl

Programmer
Mar 21, 2004
3
0
0
IL
Hi all,

I'm trying to do a lookup to bean:

Object obj = ctx.lookup( "ejb/myPackage/mySessionBeanHome" );
javax.rmi.PortableRemoteObject.narrow( obj, mySessionBeanHome.class );

and I'm getting the following exception:

Exception in thread "P=874250:O=0:CT" java.lang.ClassCastException: cannot cast class org.omg.stub.java.rmi._Remote_Stub to interface myPackage.mySessionBeanHome
at com.ibm.rmi.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:409 )
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:156)
at myPackage.MyClient.main(MyClient.java:73)


I investigated the object that returned from the lookup:

Class Name:
org.omg.stub.java.rmi._Remote_Stub

Methods:
0)_ids
1)hashCode
2)equals
3)toString
4)connect
5)_get_codebase
6)_get_delegate
7)_set_delegate
8)_duplicate
9)_release
10)_is_a
11)_is_equivalent
12)_non_existent
13)_hash
14)_request
15)_create_request
16)_create_request
17)_get_interface_def
18)_orb
19)_get_policy
20)_get_domain_managers
21)_set_policy_override
22)_is_local
23)_servant_preinvoke
24)_servant_postinvoke
25)_request
26)_invoke
27)_releaseReply
28)getClass
29)notify
30)notifyAll
31)wait
32)wait
33)wait

Fields:
None

Constructors:
0)org.omg.stub.java.rmi._Remote_Stub


How come the lookup not return my home interface?

Thanks,
Alon
 
Strangely, when I narrow the returned object to javax.ejb.EJBObject,
I don't get an exception:

javax.rmi.PortableRemoteObject.narrow( obj, javax.ejb.EJBObject.class );

As far as I see my deployment descriptor is fine...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top