0

I am learning RMI by myself now.I put all my files in the same directory and they are working well.But after I separate the server and client in different directory,there will be an error said RemoteException java.rmi.UnmarshalException: error unmarshalling return; nested exception is: java.lang.ClassNotFoundException: CalculatorImpl_Stub (no security manager: RMI class loader disabled). I dont know how to fix it.and here is my code :

Server
import java.rmi.Naming;

public class CalculatorServer{
    public CalculatorServer(){
        try{
            Calculator c = new CalculatorImpl();
            Naming.rebind("rmi://localhost:1099/CalculatorService", c);
        }catch(Exception e){
            System.out.println("Trouble: "+ e);
        }
    }
    public static void main(String args[]){
        new CalculatorServer();
    }
}



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://localhost/CalculatorService");
        System.out.println(c.sub(4,3));
        System.out.println(c.add(4,5));
        System.out.println(c.mul(3,6));
        System.out.println(c.div(9,3));
    }catch(MalformedURLException murle){
        System.out.println();
        System.out.println("MalformedURLException");
        System.out.println(murle);
    }
    ....
}
Noel
  • 10,152
  • 30
  • 45
  • 67
user3068520
  • 37
  • 1
  • 6
  • http://stackoverflow.com/questions/6322107/java-no-security-manager-rmi-class-loader-disabled might have answers – zapl Dec 05 '13 at 03:47

1 Answers1

0

You've over-separated. Some of the .class files are common to both the server and the client. The class mentioned in the exception is one of them, and so are any others that show up in subsequent such exceptions.

user207421
  • 305,947
  • 44
  • 307
  • 483