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 :

java.lang.IllegalArgumentException: argument type mismatch


Sujet :

Struts 1 Java

  1. #1
    Futur Membre du Club
    Inscrit en
    Décembre 2008
    Messages
    9
    Détails du profil
    Informations forums :
    Inscription : Décembre 2008
    Messages : 9
    Points : 6
    Points
    6
    Par défaut java.lang.IllegalArgumentException: argument type mismatch
    Salut !

    Je suis en train de réaliser un projet avec le framework Struts.
    Donc,en bref, j'ai une page inscription_candidat.jsp et une autre creer_cv.jsp.
    Lors de la creation de compte je veux stocker les informations de compte dans bean(candidat) puis faire une redirection vers la page creer_cv.jsp pour créer le Cv du candidat et enfin sauvegarder les champs dans la BD.

    J'aurais besoin d'aide... J'ai un problème que je n'arrive pas à résoudre.

    voici l'erreur :

    cause mère

    javax.servlet.ServletException: BeanUtils.populate
    org.apache.struts.util.RequestUtils.populate(RequestUtils.java:475)
    org.apache.struts.chain.commands.servlet.PopulateActionForm.populate(PopulateActionForm.java:50)
    org.apache.struts.chain.commands.AbstractPopulateActionForm.execute(AbstractPopulateActionForm.java:60)
    org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
    org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
    org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)
    org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
    org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

    cause mère

    java.lang.IllegalArgumentException: argument type mismatch
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1789)
    org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.java:1684)
    ....
    voici mes ressources:

    inscription_candidat.jsp

    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
    <html:form action="/creer_cv">
    	<table align="center">
    		<tr>
    			<td>Civilite</td>
    			<td>Nom</td>
    			<td>Prenom</td>
    		</tr>
    		<tr>
    		<td><html:text property="civilite" name="candidat"/>
    			</td>
    			<td><html:text property="nomCnd" name="candidat" /></td>
    			<td><html:text property="prenomCnd" name="candidat" /></td>
    		</tr>
    		<tr>
    			<td>Date Naissance</td>
    			<td>Ville</td>
    			<td>Pays</td>
    		</tr>
    		<tr>
    			<td><html:text property="dateNaissanceCnd"
    				name="candidat" /></td>
    			<td><html:text property="villeCnd" name="candidat" /></td>
    			<td><html:text property="paysCnd" name="candidat" /></td>
    		</tr>
    		<tr>
    			<td colspan="3">Adresse</td>
    		</tr>
    		<tr style="height: 37px;">
    			<td colspan="3"><html:textarea property="adresseCnd"
    				name="candidat" style=" width : 484px;" /></td>
    		</tr>
    		<tr>
    			<td>Tél Portable</td>
    			<td>Tél Fixe</td>
    			<td>Code Postale</td>
    		</tr>
    		<tr>
    			<td><html:text property="telPortanleCnd" name="candidat" /></td>
    			<td><html:text property="telFixeCnd" name="candidat" /></td>
    			<td><html:text property="codePostale" name="candidat" /></td>
    		</tr>
    		<tr>
    			<td colspan="3">Photo</td>
    		</tr>
    		<tr>
    			<td colspan="3"><html:file property="photo" name="candidat"
    				style=" width : 444px;" /></td>
    		</tr>
    		<tr>
    			<td colspan="3">Identifiants ITrecrute</td>
    		</tr>
    		<tr>
    			<td colspan="3">
    			<table>
    				<tr>
    					<td>E-mail</td>
    					<td>Confirmation E-mail</td>
    				</tr>
    				<tr>
    					<td><html:text property="emailCnd" name="candidat" /></td>
    					<td><html:text property="emailCnd" /></td>
    				</tr>
    				<tr>
    					<td>Mot de Passe</td>
    					<td>Confirmation Mot de Passe</td>
    				</tr>
    				<tr>
    					<td><html:text property="motPasseCnd" name="candidat" /></td>
    					<td><html:text property="motPasseCnd" /></td>
    				</tr>
    			</table>
    			</td>
    		</tr>
    		<tr>
    			<td colspan="3" align="right"><html:submit
    				value="Créer Mon Compte" /></td>
    		</tr>
    	</table>
    </html:form>
    Candidat.java

    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
    package modeles_candidat;
     
    // Generated 29 juil. 2010 14:21:09 by Hibernate Tools 3.2.2.GA
     
    import java.util.Date;
    import java.util.HashSet;
    import java.util.Set;
     
    import javax.servlet.http.HttpServletRequest;
     
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
     
    import modeles_generale.Civilite;
    import modeles_generale.Langue;
    import modeles_recruteur.Offre;
     
    /**
     * Candidat generated by hbm2java
     */
    public class Candidat extends ActionForm implements java.io.Serializable {
     
    	/**
             * 
             */
    	private static final long serialVersionUID = 1L;
    	private String nomCnd;
    	private String prenomCnd;
    	private Date dateNaissanceCnd;
    	private String adresseCnd;
    	private String telFixeCnd;
    	private String telPortanleCnd;
    	private String villeCnd;
    	private String paysCnd;
    	private String codePostale;
    	private String emailCnd;
    	private String motPasseCnd;
    	private Civilite civilite;
    	private String photo;
     
    	public Candidat() {
    	}
     
    	public String getNomCnd() {
    		return this.nomCnd;
    	}
     
    	public void setNomCnd(String nomCnd) {
    		this.nomCnd = nomCnd;
    	}
     
    	public String getPrenomCnd() {
    		return this.prenomCnd;
    	}
     
    	public void setPrenomCnd(String prenomCnd) {
    		this.prenomCnd = prenomCnd;
    	}
     
    	public Date getDateNaissanceCnd() {
    		return this.dateNaissanceCnd;
    	}
     
    	public void setDateNaissanceCnd(Date dateNaissanceCnd) {
    		this.dateNaissanceCnd = dateNaissanceCnd;
    	}
     
    	public String getAdresseCnd() {
    		return this.adresseCnd;
    	}
     
    	public void setAdresseCnd(String adresseCnd) {
    		this.adresseCnd = adresseCnd;
    	}
     
    	public String getTelFixeCnd() {
    		return this.telFixeCnd;
    	}
     
    	public void setTelFixeCnd(String telFixeCnd) {
    		this.telFixeCnd = telFixeCnd;
    	}
     
    	public String getTelPortanleCnd() {
    		return this.telPortanleCnd;
    	}
     
    	public void setTelPortanleCnd(String telPortanleCnd) {
    		this.telPortanleCnd = telPortanleCnd;
    	}
     
    	public String getVilleCnd() {
    		return this.villeCnd;
    	}
     
    	public void setVilleCnd(String villeCnd) {
    		this.villeCnd = villeCnd;
    	}
     
    	public void setCodePostale(String codePostale) {
    		this.codePostale = codePostale;
    	}
     
    	public String getCodePostale() {
    		return codePostale;
    	}
     
    	public String getPaysCnd() {
    		return this.paysCnd;
    	}
     
    	public void setPaysCnd(String paysCnd) {
    		this.paysCnd = paysCnd;
    	}
     
    	public String getEmailCnd() {
    		return this.emailCnd;
    	}
     
    	public void setEmailCnd(String emailCnd) {
    		this.emailCnd = emailCnd;
    	}
     
    	public String getMotPasseCnd() {
    		return this.motPasseCnd;
    	}
     
    	public void setMotPasseCnd(String motPasseCnd) {
    		this.motPasseCnd = motPasseCnd;
    	}
     
    	public Civilite getCivilite() {
    		return civilite;
    	}
     
    	public void setCivilite(Civilite civilite) {
    		this.civilite = civilite;
    	}
     
     
    	public void setPhoto(String photo) {
    		this.photo = photo;
    	}
     
    	public String getPhoto() {
    		return photo;
    	}
     
    }
    Civilite.java

    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
    package modeles_generale;
     
    // Generated 29 juil. 2010 14:31:12 by Hibernate Tools 3.2.2.GA
     
    /**
     * Civilite generated by hbm2java
     */
    public class Civilite implements java.io.Serializable {
     
    	/**
             * 
             */
    	private static final long serialVersionUID = 1L;
    	private int idCivilite;
    	private String libelleCivilite;
     
    	public Civilite() {
    	}
     
    	public Civilite(String libelleCivilite) {
    		this.libelleCivilite = libelleCivilite;
    	}
     
    	public int getIdCivilite() {
    		return this.idCivilite;
    	}
     
    	public void setIdCivilite(int idCivilite) {
    		this.idCivilite = idCivilite;
    	}
     
    	public String getLibelleCivilite() {
    		return this.libelleCivilite;
    	}
     
    	public void setLibelleCivilite(String libelleCivilite) {
    		this.libelleCivilite = libelleCivilite;
    	}
     
    }
    struts-config.xml:

    Code xml : 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
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
                                   "http://struts.apache.org/dtds/struts-config_1_3.dtd">
    <struts-config>
     <data-sources/>
     <form-beans>
      <form-bean name="candidat" type="modeles_candidat.Candidat"/>
      <form-bean name="civilite" type="modeles_generale.Civilite"/>
     </form-beans>
     <global-exceptions/>
     <global-forwards/>
     <action-mappings>
      <action   path="/inscription_candidat" parameter="/inscription_candidat.jsp"
      type="org.apache.struts.actions.ForwardAction"/>
      <action name="candidat" path="/creer_cv"
       scope="session" parameter="/creer_cv.jsp"
    type="org.apache.struts.actions.ForwardAction"/>
     </action-mappings>
     <controller/>
    </struts-config>

    je crois que l'erreur vient soit du champs dateNaissanceCnd ou civilite
    merci d'avance

  2. #2
    Expert éminent

    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
    Points : 7 778
    Points
    7 778
    Par défaut
    Tu ne peux pas coder un html:text sur l'objet de type Civilité.
    Il faut ajouter la propriété de l'object Civilité que tu veux pouvoir modifier :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <html:text property="civilite.libelleCivilite" name="candidat"/>
    Quant à la propriété dateNaissanceCnd, il faut la définir de type String dans l'ActionForm et ensuite la convertir en Date dans l'Action qui s'exécute au submit du formulaire.

  3. #3
    Futur Membre du Club
    Inscrit en
    Décembre 2008
    Messages
    9
    Détails du profil
    Informations forums :
    Inscription : Décembre 2008
    Messages : 9
    Points : 6
    Points
    6
    Par défaut
    Merci beaucoup pour votre réponse

  4. #4
    Futur Membre du Club
    Inscrit en
    Décembre 2008
    Messages
    9
    Détails du profil
    Informations forums :
    Inscription : Décembre 2008
    Messages : 9
    Points : 6
    Points
    6
    Par défaut
    Salut,
    j'ai essaye ce code
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <html:text property="civilite.libelleCivilite" name="candidat"/>
    mais j'ai erreur suivant:

    exception

    javax.servlet.ServletException: org.apache.jasper.JasperException: An exception occurred processing JSP page /inscription_candidat.jsp at line 20

    17: <td>Prenom</td>
    18: </tr>
    19: <tr>
    20: <td><html:text property="civilite.libelleCivilite" name="candidat"/>
    21: </td>
    22: <td><html:text property="nomCnd" name="candidat" /></td>
    23: <td><html:text property="prenomCnd" name="candidat" /></td>


    Stacktrace:
    org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286)
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    ...
    cause mère

    javax.servlet.jsp.JspException: Invalid argument looking up property: "civilite.libelleCivilite" of bean: "candidat"
    org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:887)
    org.apache.struts.taglib.html.BaseFieldTag.prepareValue(BaseFieldTag.java:126)
    org.apache.struts.taglib.html.BaseFieldTag.renderInputElement(BaseFieldTag.java:102)
    org.apache.struts.taglib.html.BaseFieldTag.doStartTag(BaseFieldTag.java:80)
    org.apache.jsp.inscription_005fcandidat_jsp._jspx_meth_html_005ftext_005f0(inscription_005fcandidat_jsp.java:287)
    org.apache.jsp.inscription_005fcandidat_jsp._jspx_meth_html_005fform_005f0(inscription_005fcandidat_jsp.java:149)
    org.apache.jsp.inscription_005fcandidat_jsp._jspx_meth_html_005fhtml_005f0(inscription_005fcandidat_jsp.java:110)
    org.apache.jsp.inscription_005fcandidat_jsp._jspService(inscription_005fcandidat_jsp.java:79)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    ...

  5. #5
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Points : 15 059
    Points
    15 059
    Par défaut
    Bonjour,

    Définies la propriété civilite de candidat avec bean:define et c'est à partir de cela que récupère l'attribut libelleCivilite.

    A+.

  6. #6
    Futur Membre du Club
    Inscrit en
    Décembre 2008
    Messages
    9
    Détails du profil
    Informations forums :
    Inscription : Décembre 2008
    Messages : 9
    Points : 6
    Points
    6
    Par défaut
    Bonjour,
    j'ai vue ta réponse mais j'ai pas bien compris si tu peux me donnée un exemple
    Merci d'avance

  7. #7
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Points : 15 059
    Points
    15 059
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    <bean:define id="civ" property="civilite" name="candidat"/>
    <html:text property="libelleCivilite" name="civ"/>

Discussions similaires

  1. Réponses: 0
    Dernier message: 10/07/2012, 10h22
  2. Réponses: 1
    Dernier message: 29/05/2012, 15h04
  3. Réponses: 3
    Dernier message: 14/03/2011, 17h12
  4. java.lang.IllegalArgumentException: type mismatch
    Par khaoula_14_05 dans le forum JSF
    Réponses: 2
    Dernier message: 30/04/2008, 14h38
  5. IllegalArgumentException: argument type mismatch
    Par mastamx dans le forum Hibernate
    Réponses: 1
    Dernier message: 22/11/2007, 16h43

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