Je suis nouveau à la technologie RMI.Obtenir java.rmi.UnmarshalException: hachage méthode non reconnue: méthode non prise en charge par l'objet distant
Lorsque j'exécute le programme client rmi, j'obtiens l'exception: java.rmi.UnmarshalException: méthode non reconnue hash: méthode non prise en charge par l'objet distant. J'utilise jdk1.5
L'argument de la méthode à distance est l'objet sérialisé.
Ce sont le code du serveur ...
Ceci est l'interface à distance
package interfacepackage;
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface ServerInterface extends Remote{
public void getOrder(Order order) throws RemoteException;
}
Ceci est la classe d'implémentation du serveur
public class ServerImplementation implements ServerInterface {
public ServerImplementation() throws RemoteException {
}
public void getOrderFromCash(Order order) throws RemoteException {
System.out.println("WORKED");
}
public static void main(String[] args)
try {
java.rmi.registry.LocateRegistry.createRegistry(1234);
ServerImplementation service = new ServerImplementation();
ServerInterface myRemoteObject = (ServerInterface) UnicastRemoteObject
.exportObject(service, 0);
java.rmi.registry.Registry registry = java.rmi.registry.LocateRegistry
.getRegistry("localhost", 1234);
registry.rebind("ServerImplementation", myRemoteObject);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Voici l'ordre de classe
public class Order implements Serializable{
private static final long serialVersionUID = 1L;
private int id;
private String name;
public Order(int id,String name){
this.id=id;
this.name=name;
}
}
J'ai la même classe d'interface et de commande dans le client également.
Ceci est le code client
public class TestClientProgram {
public static void main(String[] args) {
try{
java.rmi.registry.Registry registry = java.rmi.registry.LocateRegistry.getRegistry("localhost",1234);
ServerInterface service=(ServerInterface) registry.lookup("ServerImplementation");
Order orderObject=new Order(1,"dish");
service.getOrderFromCash(orderObject);
}
catch(Exception e){
e.printStackTrace();
}
}
}
Quelqu'un pourrait-il me aider à comment puis-je résoudre le problème?
Merci à l'avance Renjith M
Avez-vous commencé à répondre? –