• 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
  • Himai Minh
  • Carey Brown
  • salvin francis

RMI Newbie

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I'm new to RMI. I've been tying to run the well-known calculator example for 3 days now, but to no avail. I'm starting to give up learning RMI. Please help me discover why the remote method doesn't get invoked !!

On computer number 1 (which has the name "Server0" on the network), and specifically in a folder named "CALC" I have the following files :

Calculator.class (This is the interface)

CalculatorImpl.class (Implementation of the interface)

CalculatorImpl_Stub.class (stub generated using rmic)
Automatically generated ...


On this machine (Server0), I launched MS. DOS, unset the classpath, and ran rmiregistry :
C:\CALC>set classpath=

I then opened another instance of MS. DOS to set the classpath, set the security policty and run the server:
C:\CALC>set classpath=c:\calc
C:\CALC>java -Djava.security.policy=java.policy CalculatorImpl

So far, so good, No errors !

On the other machine, that is on the same network, I have the following files in a folder named "CALC" :

Calculator.class (This is the interface)
See code above.

CalculatorClient.java (This is the client)
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.net.MalformedURLException;
import java.rmi.NotBoundException;

public class CalculatorClient {

public static void main(String[] args) {
try {
Calculator c = (Calculator) Naming.lookup("rmi://Server0/CalculatorService");
System.out.println( c.sub(4, 3) );
catch (Exception e) {System.out.println("Error returning stub and invoking remote method on stub");}


see code above

Similarly, I launched an instance of MS DOS and typed:
C:\CALC>set classpath=

Launched another instance and typed:
C:\CALC>set classpath=c:\calc
C:\CALC>java -Djava.security.policy=java.policy -Djava.rmi.server.codebase=http://Server0/CalculatorService/ CalculatorClient

An Exception was caught, and the msg "Error returning stub and invoking remote method on stub" was printed.

Any help will be greatly appreciated !
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post the entire error message?

How are the two machines connected on the network? Any firewalls between them?

Plus, you only need to run the rmiregistry on the server machine. You don't need to run it on the client (this isn't causing any problem, but it's not needed to run).
What's that smell? Hey, sniff this tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic