Bonjour, je requiers votre aide pour un problème de désérialization avec XMLDecoder, il plante en me sortant une noSuchMethodException sur chaque setter de ma classe, or ces setters ont bien été créé (automatiquement avec Netbeans) et la meme méthode marche pour une autre classe.

je vous poste mon code:


Modele.Sport
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
 
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
 
package Modeles;
 
import java.util.ArrayList;
import Controles.Serial;
import java.util.Iterator;
import javax.swing.JOptionPane;
 
/**
 *
 * @author maxiflo
 */
public class Sport implements java.io.Serializable {
 
    private String nomSport;
    private int nbMiTemps;
    private int dureeMiTemps;
    private int nbJoueurs;
    private int nbRemplacents;
    private String adresseServeur;
    private boolean ajout;
    private boolean supp;
    private ArrayList<Sport> listeSport;
    private Serial leSerial;
    private boolean modif;
    private Iterator<Sport> it;
    private Sport leSport;
 
 
    /**
     * Constructreur par defaut de la classe, sert à implémenter la serialization.
     * 
     */
    public Sport() {
 
        nomSport = null;
        nbMiTemps = 0;
        dureeMiTemps = 0;
        nbJoueurs = 0;
        nbRemplacents = 0;
        adresseServeur = null;
 
 
        initialize();
 
    }
 
    /**
     * Constructeur simple de la classe, sert entre autres à la suppression
     * 
     * @param vnom -> le nom du sport
     */
    public Sport(String vnom) {
 
        nomSport = vnom;
        nbMiTemps = 0;
        dureeMiTemps = 0;
        nbJoueurs = 0;
        nbRemplacents = 0;
        adresseServeur = null;
 
 
        this.initialize();
 
    }
 
    /**
     * Constructeur de la classe
     * 
     * @param vnomSport -> le nom du sport.
     * @param vnbMiTemps -> le nombre de mi-temps.
     * @param vdureeMiTemps -> la duree de la mi-temps.
     * @param vnbJoueurs -> le nombre de joueurs sur le terrain.
     * @param vnbRemplacents -> le nombre de joueurs remplacents.
     * @param vadresseServeur -> l'adresse du serveur fédéral, pour reupérer des infos.
     */
    public Sport(String vnomSport, int vnbMiTemps, int vdureeMiTemps, 
            int vnbJoueurs, int vnbRemplacents, String vadresseServeur) {
 
        nomSport = vnomSport;
        nbMiTemps = vnbMiTemps;
        dureeMiTemps = vdureeMiTemps;
        nbJoueurs = vnbJoueurs;
        nbRemplacents = vnbRemplacents;
        adresseServeur = vadresseServeur;
 
        this.initialize();
 
    }
 
    /**
     * Méthode qui contient les instructions à réaliser lorsqu'on instancie la classe.
     */
    private void initialize() {
 
 
 
 
    }
 
    /**
     * Méthode qui rajoute un sport.
     * 
     * @param vleSport -> le sport à ajouter.
     * @return ajout -> booleen qui indique si l'ajout a été réalisé ou pas.
     */
    public boolean ajoutSport (Sport vleSport){
 
        listeSport = new ArrayList<Sport>();
        ajout = listeSport.add(vleSport);
 
        if (ajout == true) {
 
            //on effectue la serialization
            Serial.Serialize(listeSport, "conf/sports.conf");   
            listeSport = loadSport();
            JOptionPane.showMessageDialog(null, "L'ajout du compte a été effectué.", "Ajout effectué", JOptionPane.INFORMATION_MESSAGE);
        }
        else {
 
            JOptionPane.showMessageDialog(null, "L'ajout du sport dans l'ArrayList a échoué." +
                   " Veuillez vérifier votre saisie.", "Echoué", JOptionPane.ERROR_MESSAGE);
        }
 
 
    return ajout;
    }
 
    public Sport loadConfSport (String vnom){
 
        listeSport = new ArrayList<Sport>();
        listeSport = loadSport();
 
 
        it = listeSport.iterator();    
 
        int j = 0;
 
        for (int i = 0;it.hasNext();i++) {
 
            while (j == 0){
 
                leSport = it.next();
                nomSport = leSport.getNomSport();
 
                //System.out.println(vnom);
 
                if (nomSport.equals(vnom)){
                   j = 1;
                }
            }
        }
 
        if (j == 0){
            Sport leNewSport = new Sport();
            leSport = leNewSport;
        }
 
        return leSport;
    }    
    /**
     * Methode qui modifie les information d'un sport.
     * 
     * @param vleSport -> le sport actualisé.
     * @return modif -> actualisé ou pas.
     */
    public boolean modifSport (Sport vleSport) {
 
        it = listeSport.iterator();
        Sport unSport = new Sport();
 
 
        for (int i = 0;it.hasNext();i++) {
 
            leSport = it.next();
            nomSport = unSport.getNomSport();
 
            if (nomSport.equals(vleSport.getNomSport())){
 
                int j = i;
               listeSport.remove(j);
              modif = listeSport.add(vleSport);
 
              Serial.Serialize(listeSport, "conf/sports.conf");
              listeSport = loadSport();
            }
        }
 
 
    return modif;
    }
 
    /**
     * Méthode qui supprime un sport
     * 
     * @param vleSport -> le sport a supprimer.
     * @return supp -> supprimer ou pas;
     */
    public boolean suppSport(Sport vleSport) {
 
        it = listeSport.iterator();
        Sport unSport = new Sport();
 
        supp = false;
 
 
        for (int i = 0;it.hasNext();i++) {
 
            leSport = it.next();
            nomSport = unSport.getNomSport();
 
            if (nomSport.equals(vleSport.getNomSport())){
 
                int j = i;
               listeSport.remove(j);
               supp = true;
 
              Serial.Serialize(listeSport, "conf/sports.conf");
              listeSport = loadSport();
            }
        }
 
        return supp;
    }
 
    /**
     * Methode qui recupere les differentes configurations des sports dans le 
     * fichier conf et les organise dans un ArrayList.
     * 
     * @return listeSport -> la liste des sports, sous forme d'ArrayList.
     */
    public ArrayList loadSport() {
 
        listeSport = new ArrayList<Sport>();
        leSerial = new Serial();
        //System.out.println("test007");
        try {
        listeSport = leSerial.Deserialize("conf/sports.xml");
        System.out.println("reussi");
        }
        catch (java.io.IOException e){
            System.out.println("erreur");
            e.printStackTrace();
        }
        System.out.println("test0");
        return listeSport;
    }
 
     //--------------------------------------------------------
   //            GETTERS ET SETTERS
   //-------------------------------------------------------
 
 
    public String getAdresseServeur() {
        return adresseServeur;
    }
 
    public void setAdresseServeur(String adresseServeur) {
        this.adresseServeur = adresseServeur;
    }
 
    public int getDureeMiTemps() {
        return dureeMiTemps;
    }
 
    public void setDureeMiTemps(int dureeMiTemps) {
        this.dureeMiTemps = dureeMiTemps;
    }
 
    public int getNbJoueurs() {
        return nbJoueurs;
    }
 
    public void setNbJoueurs(int nbJoueurs) {
        this.nbJoueurs = nbJoueurs;
    }
 
    public int getNbMiTemps() {
        return nbMiTemps;
    }
 
    public void setNbMiTemps(int nbMiTemps) {
        this.nbMiTemps = nbMiTemps;
    }
 
    public int getNbRemplacents() {
        return nbRemplacents;
    }
 
    public void setNbRemplacents(int nbRemplacents) {
        this.nbRemplacents = nbRemplacents;
    }
 
    public String getNomSport() {
        return nomSport;
    }
 
    public void setNomSport(String nomSport) {
        this.nomSport = nomSport;
    }
 
 
 
 
 
}
Controles.DemandeSport
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
 
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
 
package Controles;
 
import Modeles.Sport;
 
/**
 *
 * @author maxiflo
 */
public class DemandeSport {
 
    private boolean ajout;
    private boolean modif;
    private boolean supp;
    private Sport leSport;
 
    public DemandeSport() {
 
    }
 
    public boolean demandeAjout(String vnom,int vnbmitps,int vdureemitps,int vnbjoueurs, int vnbremp, String vadresseServeur ){
 
        ajout = false;
 
        leSport = new Sport (vnom, vnbmitps, vdureemitps, vnbjoueurs, vnbremp, vadresseServeur);
 
        ajout = leSport.ajoutSport(leSport);
 
        return ajout;
    }
 
    public boolean demandeSupp(String vnom){
 
        supp = false;
 
        leSport = new Sport(vnom);
 
        supp = leSport.suppSport(leSport);
 
        return supp;
    }
 
}
Ma classe Serial
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
 
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
 
package Controles;
 
import java.beans.ExceptionListener;
import java.beans.XMLDecoder;
import java.beans.XMLEncoder;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
 
/**
 *
 * @author maxiflo
 */
public class Serial implements java.io.Serializable {
 
    private ArrayList liste;
    private FileInputStream fis;
 
    /**
     * Constructeur par défaut.
     */
    public Serial(){
 
    }
 
    /**
     * Cette méthode, trouvé telle quelle, permet de sérializer au format xml un arraylist
     * 
     * @param l -> l'ArrayList à sérializer.
     */
    public static void Serialize(ArrayList l, String vfileName){
 
        try {
 
            FileOutputStream fos = new FileOutputStream(vfileName);
 
            XMLEncoder xenc = new XMLEncoder(fos);
 
            xenc.writeObject(l);
 
            xenc.close();
 
            fos.close();
 
        } 
        catch (FileNotFoundException e) {// TODO Auto-generated catch block
 
         e.printStackTrace();} catch (IOException e) {
 
 
        }
    }
 
    /**
     * Cette méthode, trouvée telle quelle, permet de désérializer un fichier xml 
     * dans un ArrayList.
     * 
     * @param vfichier -> le fichier a déserializer.
     * 
     * @return listeCompte -> un arraylist avec tous les comptes.
     */
    public ArrayList Deserialize(String fileName) throws FileNotFoundException, IOException {
 
        liste = new ArrayList();
    // ouverture de decodeur
       fis = new FileInputStream(fileName);
 
    XMLDecoder decoder = new XMLDecoder(fis, null, new ExceptionListener() {
    public void exceptionThrown(Exception exception) {
        exception.printStackTrace();
    }
});
 
 
    try {
        // deserialisation de l'objet
        liste = (ArrayList) decoder.readObject();
    } finally {
        // fermeture du decodeur
        decoder.close();
    }                      
 
    return liste;
 
 }
 
 
}

Voila je pense avoir mis tuot ce qu'il faut, je précise que la sérialization marche sans problème. Toute aide ou toute critique constructive de mon travail est la bienvenue,

merci d'avance