Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
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


Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
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