• 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Question about RMI

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I have stubs running on my machine, in order to call the methods running on some other machine somewhere in the world, I would
call lookup on context and
call narrow on PortableRemoteObject and
call create on the home object as follows:
InitialContext context = new InitialContext();
Object o = context.lookup(jndiNameOfHomeObject);
Home h =
(Home) PortableRemoteObject.narrow(
o,
com.ejb.bmpHome.class);
h.create(param1, param2,�.);

But how does the stub running on my client machine know where in the world is the skeleton is or where is the real method running (the machine name where the method is running). Where do I set that up in the server or where do I mention that in the program?
Thanks in advance.
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You would mention the JNDI lookup name on the DD and the container should take care of making this object available to you once the bean is deployed. I am talking about the EJB-JAR xml file.
 
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Alex,

Q. the machine name where the method is running

A. it's all in the InitialContext. Please note that an instance of the InitialContext can be created
1) with the Hashtable populated with the key/value pairs, one of these pairs would have the provider url, on which the remote class is running
2) with no arguments; all initial context variables are picked up from jndi.properties file.

Eg, JBoss jndi properties file:


java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp://localhost:1099
java.naming.factory.url.pkgs=org.jboss.naming rg.jnp.interfaces

 
Alex George
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for all the replies. So once I got the jar file (with the RMI code), I would have to put that in the build path, then put the jndi name in the ejb-jar.xml. But how do I map the jndi name in the ejb-jar file and the jndi properties file?
 
Deepak Bala
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The container will take care of binding the JNDI name to its context. The JNDI properties will identify which JNDI initial context to connect to. Its for your client
 
Alex George
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess my question is if I get ejb client jars from developers sitting in the other side of the world, how do I set that up in order to call methods in them? I thing the first step is to put the jar file in the build path. Then I put the name in the deployment descriptor (In case of websphere this is ibm-ejb-jar-bnd.xmi. In case of jboss this is jboss.xml). Then where do I specify the name of the remote machine the real method is running (where the skeleton is)?
 
You showed up just in time for the waffles! And 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
reply
    Bookmark Topic Watch Topic
  • New Topic