Bonjour,


j'essaie d'envoyer une image sérialisée depuis un Client vers un serveur multi-clients qui a comme rôle de stocker les images qu'on lui envoie.


Code 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
public void EnvoiPhoto(String path, String annot, Boolean visib) throws Exception{
 
                chemin_p = path.substring(path.lastIndexOf("\\"));
                chemin_p = chemin_p.substring(1,chemin_p.length());
 
                FileInputStream photo = new FileInputStream(path);
                byte[] octets = new byte[photo.available()];
 
                Photo Ph=new Photo(octets,chemin_p,annot,visib);
                ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
                oos.writeObject(Ph);
                oos.flush();
 
		System.out.println("SOCKET "+socket);
		System.out.println("image envoyee");
    }


Code Serveur :

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
26
27
28
29
30
31
32
33
34
 
    //BufferedReader => in;
    //PrintWriter => out;
 
 
   public void run() {
        try {
          while (true) {                
                if(nb>=20)
                    out.println("trop d'images, veuillez en supprimer");
                else{
                        FileInputStream fichier=new FileInputStream("Ph.ser");
                        ObjectInputStream flux=new ObjectInputStream(socket.getInputStream());
                    try{
                        Photo photoClient = (Photo) flux.readObject();
                        System.out.println("Photo :"+photoClient.getAnnotation());
                        System.out.println("Mot clé :"+photoClient.getNom());                                
                    } catch (Exception ex) {
                        System.err.print("Erreur de reception");
                    }
              }
          }
        } catch(IOException e) {
          System.err.println("IO Exception");
        } finally {
          try {
            socket.close();
            in.close();
            out.close();
          } catch(IOException e) {
            System.err.println("Socket not closed");
          }
        }
    }


Client et Serveur possède tous les 2 la classe Photo qui permet de sérialiser l'image envoyée.
Mais à chaque fois que je lance ça j'ai l'exception "Erreur de reception" (voici l'excption : GRAVE: null java.lang.ClassNotFoundException: projeti4b_client.Photo )

Quelqu'un voit où est l'erreur ? (paramètre byte[] de la photo sérialisée?)

Merci d'avance !