• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jdiscuss question id 1693

 
Miki Muzsi
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following code is considered to be incorrect:

Context initCtx = new InitialContext();
TaxHome taxHome = (TaxHome) PortableRemoteObject.narrow(initCtx.lookup("java:comp/env/ejb/tax"), TaxHome.class);
Tax tax = (Tax) PortableRemoteObject.narrow(taxHome.create(), Tax.class);


The explanation: "Casting using PortableRemoteObject is not done for remote interfaces returned by bean methods".

I agree the component interface doesn't need to be narrowed, nor even casting is required. But I think the code is correct and runs without any problems.

Miki
 
sawan parihar
Ranch Hand
Posts: 250
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well the way I understand it the question says "The following code is considered to be incorrect" and not that "The following code is incorrect". Although this code will work but its not correct because there is no need to narrow component interface .


Hope this helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic