Win a copy of High Performance Python for Data Analytics this week in the Python forum!

Summer Ahmad

Greenhorn
+ Follow
since Dec 16, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Summer Ahmad

Hello,

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 ...

java.policy
-----------



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

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");}

}
}

java.policy
-----------
see code above


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

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 !
16 years ago