Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

EJB 2.0 local inetrfaces

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to write a session ejb that talks to another sesion ejb using LOCAL interfaces, as per the ejb 2.0 spec.
However I am falling at the first hurdle as to how to do the lookup for the LocalHome interface object.
The way it would be done using REMOTE interfaces would be to do the javax.rmi.PortableRemoteObject.narrow on the remote home inetrface class.
But I cannot work out, and canot find an example, as the steps required to do this fgor local interfaces.
If someone can provide me with an example for this step i would be grateful.
Cheers
T
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need to do a narrow. You can simply cast the object to your home local object. Here is an example from "Enterprise Java Beans - 3rd Edition".
This is the code of a local client trying to get a reference to a local home object called CabinHomeLocal:
javax.naming.Context jndiContext = new InitialContext();
CabibHomeLocal home = (CabinHomeLocal) jndiContext.lookup("java:comp/env/ejb/CabinHomeLocal");
Hope this helps.
 
le taylom
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many thanks, good answer, it works.
T
 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, just a doubt: do you have to manually define that reference "comp/env/ejb/CabinHomeLocal"? I�m using Websphere Studio 5 from IBM, can you help me?
Francisco
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Francisco A Guimaraes:
Hi, just a doubt: do you have to manually define that reference "comp/env/ejb/CabinHomeLocal"? I�m using Websphere Studio 5 from IBM, can you help me?
Francisco


Yes, you need to define a local reference in your deployment descriptor to use local EJBs in WAS. If you want more details on this then I suggest you mosey on over to the IBM/Websphere Forum.
 
She's brilliant. She can see what can be and is not limited to what is. And she knows this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic