Help coderanch get a
new server
by contributing to the fundraiser
  • 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

Calling a EJB in a different Websphere instance

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

We need to synchronously call a EJB method on a EJB which is in a different Websphere instance. What is the code to call this from our EJB ? How do we define a reference to this other EJB since it does not exist in our deployment descriptor ?

Thanks,

Vikas
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Create InitialContext with url of that server.

Properties props = new Properties();

props.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");

props.put(Context.PROVIDER_URL,"t3://<hostname>:7001");
//props.put(Context.PROVIDER_URL,"http://<hostname>:7001");

Context ctx = new InitialContext(props);

MyEjbHome home = (MyEjbHome)ctx.lookup("ejb/myEjbHome");

home.create().....

.............
 
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Code doesnt change even if you are calling EJB which is running on other instance of Websphere or running on same instance. If it is running on same instance you can use local interfaces of EJB2.1 concept which makes the system faster retrieval of ejbs
 
We don't have time to be charming! Quick, read this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic