Estoy programando una aplicacion RMI y me sale el siguiente error al querer conectar mi cliente con el servidor :
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: RMI.IRMICustomerService (no security manager: RMI class loader disabled)
A continuación incluyo mi código.
Mi interfaz : IRMICustomerService.java
package RMI;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.Date;
public interface IRMICustomerService extends Remote {
public void createCustomer(Customer input) throws RemoteException;
public Customer getCustomer(int customerID) throws RemoteException;
}
Mi implementacion : RMICustomerService.java
package RMI;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;
public class RMICustomerService extends UnicastRemoteObject implements IRMICustomerService {
ArrayList<Customer> customerContainer = new ArrayList<Customer>();
protected RMICustomerService() throws RemoteException {
super();
// TODO Auto-generated constructor stub
Customer a = new Customer(1,"Jonathan","xxx");
Customer b = new Customer(2,"xxx","eeeee");
customerContainer.add(a);
customerContainer.add(b);
}
@Override
public void createCustomer(Customer input) throws RemoteException {
// TODO Auto-generated method stub
customerContainer.add(input);
System.out.println("ok");
}
@Override
public Customer getCustomer(int customerID) throws RemoteException {
// TODO Auto-generated method stub
return customerContainer.get(customerID);
}
}
Para la conexion : StartAndBindRegistry.java
package RMI;
import java.net.MalformedURLException;
import java.rmi.AlreadyBoundException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
public class StartAndBindRegistry {
public static void main(String[] Args) throws MalformedURLException, AlreadyBoundException {
try {
LocateRegistry.createRegistry(1099);
String name="//localhost/RMICustomer";
RMICustomerService rmi = new RMICustomerService();
Naming.bind(name, rmi);
System.out.println("Service started");
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("Could not start registry");
}
}
}
Mi cliente que se conecta : RMIAccountClient.java
package Client;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.util.Scanner;
public class RMIAccountClient {
public Customer newCustomer() {
Customer tmp = new Customer();
Scanner sc = new Scanner(System.in);
System.out.println("Please introduce the ID of the new customer:");
tmp.setId_customer(sc.nextInt());
System.out.println(tmp.getId_customer());
System.out.println("Please introduce the name of the new customer:");
tmp.setName(sc.next());
System.out.println(tmp.getName());
System.out.println("Please introduce the last name of the new customer:");
tmp.setVorname(sc.next());
System.out.println(tmp.getVorname());
sc.close();
return tmp;
}
public static void main(String[] args) {
RMIAccountClient obj = new RMIAccountClient();
String name="//localhost/RMICustomer";
Customer x = new Customer(2,"kkk","ffff");
try {
IRMICustomerService remoteService =(IRMICustomerService)Naming.lookup(name);
System.out.println(remoteService.getCustomer(1));
} catch (RemoteException e) {
// TODO Auto-generated catch block
System.out.println(e);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
System.out.println(e);
} catch (NotBoundException e) {
// TODO Auto-generated catch block
System.out.println(e);
}
}
}
Gracias de antemano!!!