• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jdiscuss question id 1693

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 250
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
It is no measure of health to be well adjusted to a profoundly sick society. -Krishnamurti Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic