File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes EJB ClassCastException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB ClassCastException" Watch "EJB ClassCastException" New topic
Author

EJB ClassCastException

Sam Wang
Ranch Hand

Joined: Jul 17, 2001
Posts: 95
When i want to get a cmp's localhome interface in the same jar,everything is ok.
When i want to get a cmp's localhome interface (called 'ItemEntity') from another jar,the exception occurs:
java.lang.ClassCastException: Cannot narrow remote object to com.XXX.ItemEntityHome
My code is like:
Context ctx=new InitialContext();
ItemEntityHome itemHome = (ItemEntityHome)PortableRemoteObject.narrow(ctx.lookup("java:/comp/env/ejb/ItemEntity"),ItemEntityHome.class);
[ May 27, 2002: Message edited by: Stub Wang ]

SCJP(2001)
Rufus BugleWeed
Ranch Hand

Joined: Feb 22, 2002
Posts: 1551
Page 486 EJBs by Monson-Hafel, O'Reilly, 3rd Edition
EJBs declared in the <ejb-local-ref> elements ... do not require use of PortableRemoteObject.narrow() ... use a simple native cast operation
Sam Wang
Ranch Hand

Joined: Jul 17, 2001
Posts: 95
Thanks,Rufus.I understand.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB ClassCastException