• 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

rmi troubles

 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone. It seems it's not only me who's struggling with RMI, but I feel that I'm struggling with the very basics of RMI. I'm not understanding something clearly about the addresses that you use to bind the Remote class in the server class. (eg : Naming.rebind("xxxxx", new Hello("Hello RMI World!!")); I'm not all that sure what goes by the x's. Also, what confused me likewise in the Client is where you lookup for a Remote Class. (eg : HelloInterface hello = (HelloInterface) Naming.lookup(xxxxx); again, I'm not sure what to put by the x's.
You see what I'm confused about is this. All the tutorials say that you put the address of the remote machine in there, and they have addresses like org.whatever.ClassName. Now all I want to do is call a Remote classes method that is on the machine next to me, Same network... lets say for simplicity sake, the machine next to me's name is Bob, his ip address is 197.0.0.5. The Remote class is sitting in his c:\ drive in the rmi folder and is called Hello.class. there is a HelloInterface, and HelloServer in the same directory. the rmiregistry is started, and the HelloServer is running. Please could someone tell me how to call the method in the Remote Hello class. Any help would be hugely appreciated, and as always, sorry for the long windedness.
Thanks
Darryl
 
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
The RMI Server makes a bind/rebind to the rmiregistry with the name 'HelloServer':

Now the client can make a lookup in the rmiregistry with the same name as the server made the rebind 'HelloServer':

You can now call the methods on the server:

/Rene
[ June 13, 2002: Message edited by: Rene Larsen ]
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Darryl -
Maybe you'll find this useful.
 
Darryl Nortje
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi again.
Firstly Thanks Rene, it worked and got me going. Michael also, thanks for the link to your lesson. I (think I) understand the basics now. I have also got A very basic rmi demo working.
The reason I started investigating RMI and how it works was this. We (my company) has a product that is basically a search engine running off a database.
What they now want me to do in a nutshell is this.-->
If a bank for example has the product in there branch "A", that is running on it's own database and someone does a search, and does not find results (or desired result) they can connect to Branch "B"'s version and do a search on their database. So I have the rmi classes client side and server side all working, but as soon as I attempt to excute the line Class.forName(dbDriver); on the server side to connect to the "servers" database the AccessControlException is thrown on the client side. I have the .policy file set to this
grant codebase "file:c:/rmi/*" {
permission java.security.AllPermission;
};
Can you help me with this please.
So I spose my question is, I RMI the correct technology to use for this problem, and if so, does anyone know why it's throwing the AccessControlException.
Thanks a million.
Darryl
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you want to get rmi working in a test environment, it's a good idea to follow Sun's advice in the RMI tutorials i.e. set up a policy file which consists of the following
grant
{
permission java.net.AllPermission;
};
not sure if I've got the syntax absolutely spot-on from off of the top of my head, but use the policytool.exe and that will give you the right syntax etc.
The effect of this is to turn OFF ALL security issues and allows you to concentrate on getting the RMI bits working without having security issues getting not only in your hair, but also in your eyes, teeth, ears and nose etc. Remember the security system is in place to stop hackers and it does a pretty good job. But it also treats innocent grafters like yourself as the most heinous criminals of all and will thwart every character of your code it can.
When you have RMI working the way you want it, you can start applying permission restrictions until it stops working anymore and then you know you've gone far enough!!
If you want to shortcut this process, you can, but you need to gen up on the Security system a great deal before you will get it working for you, rather than the other way round.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic