IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Struts 1 Java Discussion :

Prb avec SerializationUtils


Sujet :

Struts 1 Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Inscrit en
    Mars 2006
    Messages
    103
    Détails du profil
    Informations forums :
    Inscription : Mars 2006
    Messages : 103
    Par défaut Prb avec SerializationUtils
    slt a tous, j éssaye de passer en session un bean en utilisant SerializationUtils

    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
    public ActionForward onCreer(
    		ActionMapping mapping,
    		ActionForm form,
    		javax.servlet.http.HttpServletRequest request,
    		javax.servlet.http.HttpServletResponse response)
    		{
    		/*
    		 * Forward vers l'action 'creationUtilisateur' de struts
    		 */ 
     
    		ActionForm formeSession = (ActionForm) SerializationUtils.clone(form);
     
     
    		request.getSession().setAttribute("saveForm",formeSession);
     
    		return mapping.findForward(FWD_CREA);
    	}
    qd je clic sur le bouttton creer j ai le message suivant et je vois pas d ou vienne l erreur
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    ERROR [action]:253 - "Servlet.service()" pour la servlet action a généré une exception
    org.apache.commons.lang.SerializationException: java.io.NotSerializableException: java.util.RandomAccessSubList
    	at org.apache.commons.lang.SerializationUtils.serialize(SerializationUtils.java:110)
    	at org.apache.commons.lang.SerializationUtils.serialize(SerializationUtils.java:132)
    	at org.apache.commons.lang.SerializationUtils.clone(SerializationUtils.java:79)
    	at com.anam.amid.administration.action.ListeUtilisateurAction.onCreer(ListeUtilisateurAction.java:363)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:324)
    	at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
    	at com.anam.amid.referentiel.action.ReferentielAction.execute(ReferentielAction.java:130)
    	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
    merci pour votre aide

  2. #2
    Membre émérite
    Profil pro
    Développeur Back-End
    Inscrit en
    Avril 2003
    Messages
    782
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Back-End

    Informations forums :
    Inscription : Avril 2003
    Messages : 782
    Par défaut
    Bonjour,

    il y a dans les attibuts de votre ActionForm un classe "java.util.RandomAccessSubList" qui n'est pas Serializable

  3. #3
    Membre confirmé
    Inscrit en
    Mars 2006
    Messages
    103
    Détails du profil
    Informations forums :
    Inscription : Mars 2006
    Messages : 103
    Par défaut
    Citation Envoyé par fnobb
    Bonjour,

    il y a dans les attibuts de votre ActionForm un classe "java.util.RandomAccessSubList" qui n'est pas Serializable
    je vois pas d ou vienne cette classe

    voila mon ActionForm
    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
    package com.anam.amid.administration.forms;
     
    import java.util.List;
     
    import javax.servlet.ServletContext;
    import javax.servlet.http.HttpServletRequest;
     
     
    import org.apache.commons.validator.Validator;
    import org.apache.commons.validator.ValidatorException;
    import org.apache.commons.validator.ValidatorResults;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.validator.Resources;
    import org.springframework.util.StringUtils;
     
    import com.anam.amid.general.forms.PaginationForm;
     
    /**
     * 
     * @author 
     * @version 1.0 
     */
    public class AdministrationForm extends PaginationForm {
     
    	/**
             * 
             */
    	private static final long serialVersionUID = 3L;
     
    	private Integer id;
     
    	private String login;	
     
    	private String password1;
     
    	private String password2;
     
    	private String nom;
     
    	private String prenom;
     
    	private List listeProfils;
    	private String profilSelected;
     
    	private boolean actif;
     
    	private boolean enregistrementOk;	
     
    	private boolean modification;	
     
    	private boolean checkAll;
     
    	private boolean fromListe;
     
    	private String popupNotModalHandler;
     
     
    	/**
             * Override the reset method from Struts for this custom form
             * 
             * @param mapping
             * @param request
             */
    	public void reset(ActionMapping mapping, HttpServletRequest request) {
     
    		super.reset(mapping,request);	
    		checkAll=false;
    	}
     
    	/**
             * Default constructor
             */
    	public AdministrationForm() {
    		super();	
    	}
     
    	public void init()
    	{
    		super.init();
    		id=null;
    		login=null;
    		password1=null;
    		password2=null;
    		nom=null;
    		prenom=null;
    		listeProfils=null;
    		profilSelected=null;
    		actif=false;
    		enregistrementOk=false;
    		modification=false;
    		checkAll=false;
    		popupNotModalHandler=null;
    		fromListe=false;
    	}
     
    	public Integer getId() {
    		return id;
    	}
     
    	public void setId(Integer id) {
    		this.id = id;
    	}
     
    	public boolean isActif() {
    		return actif;
    	}
     
    	public void setActif(boolean actif) {
    		this.actif = actif;
    	}
     
    	public List getListeProfils() {
    		return listeProfils;
    	}
     
    	public void setListeProfils(List listeProfils) {
    		this.listeProfils = listeProfils;
    	}
     
    	public String getLogin() {
    		return login;
    	}
     
    	public void setLogin(String login) {
    		this.login = login;
    	}
     
    	public String getNom() {
    		return nom;
    	}
     
    	public void setNom(String nom) {
    		this.nom = nom;
    	}
     
    	public String getPassword1() {
    		return password1;
    	}
     
    	public void setPassword1(String password1) {
    		this.password1 = password1;
    	}
     
    	public String getPassword2() {
    		return password2;
    	}
     
    	public void setPassword2(String password2) {
    		this.password2 = password2;
    	}
     
    	public String getPrenom() {
    		return prenom;
    	}
     
    	public void setPrenom(String prenom) {
    		this.prenom = prenom;
    	}
     
    	public String getProfilSelected() {
    		return profilSelected;
    	}
     
    	public void setProfilSelected(String profilSelected) {
    		this.profilSelected = profilSelected;
    	}
     
    	public boolean isEnregistrementOk() {
    		return enregistrementOk;
    	}
     
    	public void setEnregistrementOk(boolean enregistrementOk) {
    		this.enregistrementOk = enregistrementOk;
    	}
     
    	public boolean isModification() {
    		return modification;
    	}
     
    	public void setModification(boolean modification) {
    		this.modification = modification;
    	}
    	public boolean isCheckAll() {
    		return checkAll;
    	}
     
    	public void setCheckAll(boolean checkAll) {
    		this.checkAll = checkAll;
    	}
     
    	public String getPopupNotModalHandler() {
    		return popupNotModalHandler;
    	}
    	public void setPopupNotModalHandler(String popupNotModalHandler) {
    		this.popupNotModalHandler = popupNotModalHandler;
    	}
     
    	public boolean isFromListe() {
    		return fromListe;
    	}
     
    	public void setFromListe(boolean fromListe) {
    		this.fromListe = fromListe;
    	}
     
    	/*
    	 * PARTIE VALIDATION
    	 */
     
    	/**
         * The results returned from the validation performed
         * by the <code>Validator</code>.
         */
        protected ValidatorResults validatorResults = null;
     
        /**
         * Used to indicate the current page of a multi-page form.
         */
        protected int page;
     
     
    	public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
     
    		ActionErrors errors = new ActionErrors();
     
        	if ( StringUtils.hasLength(request.getParameter("dispatch")) && request.getParameter("dispatch").equalsIgnoreCase("onEnregistrer")){ 
            ServletContext application = getServlet().getServletContext();
     
            String validationKey = getValidationKey(mapping, request);
     
            Validator validator = Resources.initValidator(validationKey,
                                 this,
                                 application, request,
                                 errors, page);
     
            try {
                validatorResults = validator.validate();
            } catch (ValidatorException e) {
     
            }
     
        	}
        	return errors;
     
    	}
     
    	 /**
         * Returns the Validation key.
         *
         * @param mapping The mapping used to select this instance
         * @param request The servlet request we are processing
         * @return validation key - the form element's name in this case
         */
        public String getValidationKey(ActionMapping mapping,
                                       HttpServletRequest request) {
     
            return mapping.getAttribute();
        }
     
    }
    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
    package com.anam.amid.general.forms;
     
    import java.util.ArrayList;
    import java.util.List;
     
    import javax.servlet.http.HttpServletRequest;
     
     
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
     
    import com.archos.conseil.softwork.framework.utilitaires.beans.CheckBean;
    /**
     * 
     * @author 
     * @version 1.0 
     */
    public class PaginationForm extends ActionForm {
     
    	/**
             * 
             */
    	private static final long serialVersionUID = 6L;
     
    	/*
    	 * La liste des resultats de la recherche (ex:recherche utilisateur)
    	 */
    	private List listeResultats;
     
    	/*
    	 * La Liste des cases a cocher selectionnées
    	 * dans le cas de la modification ou de la supression de lignes
    	 */
    	private List listeSelectionnes;
     
    	/*
    	 * Le total des lignes affichées
    	 */
    	private Integer totalLignesAffichees;
     
    	/*
    	 * La page courante
    	 */
    	private int currentPage;
     
    	/*
    	 * La numero de la derniere page pour une recherche donnée
    	 */
    	private String maxPage;
     
    	/**
             * Override the reset method from Struts for this custom form
             * 
             * @param mapping
             * @param request
             */
    	public void reset(ActionMapping mapping, HttpServletRequest request) {
     
    		listeSelectionnes=new ArrayList();
    	}
     
    	/**
             * Default constructor
             */
    	public PaginationForm() {
    		super();	
    	}
     
    	public void init()
    	{
    		listeResultats=null;
    		listeSelectionnes=null;
    		totalLignesAffichees=null;
    		currentPage=0;
    		maxPage=null;
    	}
     
    	public List getListeResultats() {
    		return listeResultats;
    	}
     
    	public void setListeResultats(List listeResultats) {
    		this.listeResultats = listeResultats;				
    	}
     
    	public List getListeSelectionnes() {
    		return listeSelectionnes;
    	}
     
    	public void setListeSelectionnes(List listeSelectionnes) {		
    		this.listeSelectionnes=listeSelectionnes;		
    	}
     
    	public boolean getListeSelectionnes(String index) {
    		return (listeSelectionnes!=null&&listeSelectionnes.size()>Integer.parseInt(index))? ((CheckBean)listeSelectionnes.get(Integer.parseInt(index))).getValue() : false;
    	}
     
    	public void setListeSelectionnes(String index,boolean valeur) {		
    		listeSelectionnes.add(new CheckBean(Integer.parseInt(index),valeur));
    	}
     
    	public Integer getTotalLignesAffichees() {
    		return totalLignesAffichees;
    	}
     
    	public void setTotalLignesAffichees(Integer totalLignesAffichees) {
    		this.totalLignesAffichees = totalLignesAffichees;
    	}
     
    	public int getCurrentPage() {
    		return currentPage;
    	}
     
    	public void setCurrentPage(int currentPage) {
    		this.currentPage = currentPage;
    	}
     
    	public String getMaxPage() {
    		return maxPage;
    	}
     
    	public void setMaxPage(String maxPage) {
    		this.maxPage = maxPage;
    	}
    }

  4. #4
    Membre émérite
    Profil pro
    Développeur Back-End
    Inscrit en
    Avril 2003
    Messages
    782
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Back-End

    Informations forums :
    Inscription : Avril 2003
    Messages : 782
    Par défaut
    sans le code moi non plus

  5. #5
    Expert confirmé

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Par défaut
    Mais quel est l'intérêt d'utiliser SerializationUtils ?

    Pourquoi ne pas mettre tout simplement scope="session" dans le mapping de l'Action dans le struts-config.xml ?

  6. #6
    Membre confirmé
    Inscrit en
    Mars 2006
    Messages
    103
    Détails du profil
    Informations forums :
    Inscription : Mars 2006
    Messages : 103
    Par défaut
    je l ai mis mais qd je recupère mon bean dans une autre action tt ses attribut sont null

  7. #7
    Expert confirmé

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Par défaut
    Mais comment récupères-tu le form-bean dans l'autre Action ?
    As-tu référencé ce form-bean dans le mapping de cette autre Action ?

Discussions similaires

  1. prb avec une requete
    Par gregal dans le forum Langage SQL
    Réponses: 4
    Dernier message: 08/03/2005, 11h59
  2. prb avec un treeview et data
    Par mikyfpc dans le forum C++Builder
    Réponses: 7
    Dernier message: 14/12/2004, 22h59
  3. [Débutant] Jframe/JInternalFrame: prb avec JScrollPane
    Par flzox dans le forum Agents de placement/Fenêtres
    Réponses: 2
    Dernier message: 12/12/2004, 00h08
  4. prb avec dbimage
    Par hrezzaz dans le forum Bases de données
    Réponses: 1
    Dernier message: 27/10/2004, 14h41
  5. [TOMCAT] prb avec le cache de certains users
    Par osmoze dans le forum Tomcat et TomEE
    Réponses: 2
    Dernier message: 07/06/2004, 15h21

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo