Bonjour,

voila quelques jours que je plante sur un probleme que je ne comprends pas trop.
Je recois une exception UnmarshalException au lancement de la connexion d'un client a un serveur avec RMI.

Les codes associés :
La classe client
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 
public class Client {
 
    private Registry registry;
    private ServeurInterface stub;
 
 
    public Client() throws RemoteException, MalformedURLException, 
                        NotBoundException {
        registry = LocateRegistry.getRegistry(10004);
        stub = (ServeurInterface) registry.lookup("Serveur");
    }
 
    public String getHello() throws RemoteException, PieceException {
        return this.stub.hello();
 
    }
 
    public static void main(String[] argv) throws RemoteException, 
                                            MalformedURLException, 
                                            NotBoundException, PieceException {
        Client c = new Client();
        System.out.println(c.getHello());
    }
}
La classe ServeurMain
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
public static void main(String[] args) throws RemoteException, 
            AlreadyBoundException, MalformedURLException, InterruptedException {
 
            ServeurInterface skeleton = (ServeurInterface) 
                 UnicastRemoteObject.exportObject(new Serveur(), 10004);
            Registry registry = LocateRegistry.createRegistry(10004);
 
            //your object to wait
            Object lockObject=new Object();
 
            registry.bind("Serveur", skeleton);            
            System.out.println("Ready..");
 
            //Synchronize to non stop server.
            synchronized(lockObject){
                    lockObject.wait();
            }
L'interface ServeurInterface
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
 
public interface ServeurInterface extends Remote {
    public String hello() throws RemoteException;
}
La classe Serveur
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
 
public class Serveur implements ServeurInterface {
    public Serveur() throws RemoteException, AlreadyBoundException, MalformedURLException {
        System.out.println("serveur créé !");
    }
 
    public String hello() {
        return "Hello";
    }
}

Le retour de la console après lancement sur client (serveur lancé auparavant) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
Exception in thread "main" java.rmi.UnmarshalException: error unmarshalling return; nested exception is: 
        java.io.EOFException
        at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
        at serveur.Client.<init>(Client.java:25) // equivalent ligne 10
        at serveur.Client.main(Client.java:56) // equivalent ligne 21
Caused by: java.io.EOFException
        at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2553)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1296)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
        ... 3 more
Java Result: 1
J'essaierai bien de me débrouiller, mais je n'arrive même pas a savoir a quoi correspond cette exception...
Merci d'avance.

Cordialement