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 :

[Strus Débutant]Pb de configuration !


Sujet :

Struts 1 Java

  1. #1
    Membre habitué
    Profil pro
    ingenieur
    Inscrit en
    Avril 2002
    Messages
    207
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : ingenieur

    Informations forums :
    Inscription : Avril 2002
    Messages : 207
    Points : 128
    Points
    128
    Par défaut [Strus Débutant]Pb de configuration !
    Help
    Bonjour à Tous.
    Je débute avec Struts et j'ai bcp de mal à afficher ma premiere Page.
    En fait j'ai repris un exemple (très simple) sur le net et j'essai de le faire tourner sous NetBeans !
    Voila j'ai installé tout le package Struts (jar, taglib, ...) et configurer
    comme il se doit : web.xml et struts-config.xml (actionServlet, les actions...)
    Quand je lance la compile totale du projet tout se passe bien (Chek de web.xml et struts-config.xml OK) !
    Aussi Tomcat me renvoie l'erreur suivante lorsque je souhaite afficher ma 1ere page :

    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
     
     
    javax.servlet.ServletException: org/apache/struts/taglib/bean/MessageTag
    	at org.netbeans.modules.tomcat.tomcat40.runtime.IDEJspServlet.service(IDEJspServlet.java:349)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
    	at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:226)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
     
    ...etc....
     
    root cause 
     
    java.lang.NoClassDefFoundError: org/apache/struts/taglib/bean/MessageTag
    	at java.lang.Class.getDeclaredConstructors0(Native Method)
    	at java.lang.Class.privateGetDeclaredConstructors(Class.java:1610)
    	at java.lang.Class.getConstructor0(Class.java:1922)
    	at java.lang.Class.newInstance0(Class.java:278)
    	at java.lang.Class.newInstance(Class.java:261)
    	at org.netbeans.modules.tomcat.tomcat40.runtime.IDEJspServlet$JspServletWrapper.load(IDEJspServlet.java:106)
    	at org.netbeans.modules.tomcat.tomcat40.runtime.IDEJspServlet$JspServletWrapper.loadIfNecessary(IDEJspServlet.java:150)
    	at org.netbeans.modules.tomcat.tomcat40.runtime.IDEJspServlet$JspServletWrapper.service(IDEJspServlet.java:160)
    	at org.netbeans.modules.tomcat.tomcat40.runtime.IDEJspServlet.serviceJspFile(IDEJspServlet.java:246)
     
    ...etc...
    Je joins également le code de la page à afficher !

    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

    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
     
     
    <html>
     
    	<head>
    		<title><bean:message key='index.title'/></title>
    	</head>
     
    	<body>
     
    	<html:errors />
     
    	<html:form action="/login">
     
    		<table width="45%" border="0">
    			<tr>
    				<td><bean:message key='index.username' /></td>
    				<td><html:text property="nom" /></td>
    			</tr>
    			<tr>
    				<td><bean:message key='index.password' /></td>
    				<td><html:password property="pass" /></td>
    			</tr>
    			<tr>
    				<td colspan="2" align="center"><html:submit /></td>
    			</tr>
    		</table>
    	</html:form>
     
    	<a href="addUser.jsp"><bean:message key='addUser'/></a>
     
    	</body>
     
    </html>


    Par avance merci à toute personne qui pourra m'aider ou me refiler une piste !!!



  2. #2
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Décembre 2003
    Messages
    46
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2003
    Messages : 46
    Points : 38
    Points
    38
    Par défaut
    Bonjour,

    as tu déclaré les taglibs dans le fichier web.xml ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    <taglib>
         <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
         <taglib-location>/WEB-INF/tlds/struts-bean.tld</taglib-location>
    </taglib>
    ou taglib-uri correspond à ton entrée dans la page jsp :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    et taglib-location à l'emplacement du fichier .tld dans le répertoire WEB-INF

  3. #3
    Membre averti
    Inscrit en
    Mars 2004
    Messages
    377
    Détails du profil
    Informations forums :
    Inscription : Mars 2004
    Messages : 377
    Points : 356
    Points
    356
    Par défaut
    NoClassDefFoundError signifie qu'il n'a pas trouvé la classe dont tu as besoin.
    Donc primo, tu vérifies que la classe porte bien le bon nom,
    et deuxio tu vérifies qu'elle est bien dans ton classpath TOMCAT ....
    Conseil :
    Mettre ton struts.jar (ou quelquechose comme çà) dans WEB-INF/lib de ton application web.
    Voili, voilou,
    8)

  4. #4
    Membre habitué
    Profil pro
    ingenieur
    Inscrit en
    Avril 2002
    Messages
    207
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : ingenieur

    Informations forums :
    Inscription : Avril 2002
    Messages : 207
    Points : 128
    Points
    128
    Par défaut
    Merci à vous pour ces réponses ultra rapides.
    C'est exactement ça !
    J'ai copié les *.jar (Struts) dans le répertoire lib et le tour est joué !
    J'ai repris également les path définis dans le web.xml et struts-config.xml
    Par contre j'ai un autre message d'erreur :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    javax.servlet.ServletException: Exception creating bean of class form.LoginForm: {1}
    	at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:471)
    	at org.apache.jsp.index$jsp._jspService(index$jsp.java:248)
    	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     
    ..etc...
    Il retrouve bien LoginForm, mais je ne vois pas ce qui cloche !!
    Merci encore à tous ceux qui peuvent me tuyauter

  5. #5
    Membre habitué
    Profil pro
    ingenieur
    Inscrit en
    Avril 2002
    Messages
    207
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : ingenieur

    Informations forums :
    Inscription : Avril 2002
    Messages : 207
    Points : 128
    Points
    128
    Par défaut
    Citation Envoyé par Ho(c)ine.
    Merci à vous pour ces réponses ultra rapides.
    C'est exactement ça !
    J'ai copié les *.jar (Struts) dans le répertoire lib et le tour est joué !
    J'ai repris également les path définis dans le web.xml et struts-config.xml
    Par contre j'ai un autre message d'erreur :

    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
     
    javax.servlet.ServletException: Exception creating bean of class form.LoginForm: {1}
    	at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:471)
    	at org.apache.jsp.index$jsp._jspService(index$jsp.java:248)
    	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     
    ..etc...
     
    root cause 
     
    javax.servlet.jsp.JspException: Exception creating bean of class form.LoginForm: {1}
    	at org.apache.struts.taglib.html.FormTag.initFormBean(FormTag.java:563)
    	at org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:520)
    	at org.apache.jsp.index$jsp._jspService(index$jsp.java:103)
    	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    	at org.netbeans.modules.tomcat.tomcat40.runtime.IDEJspServlet$JspServletWrapper.service(IDEJspServlet.java:173)
    	at org.netbeans.modules.tomcat.tomcat40.runtime.IDEJspServlet.serviceJspFile(IDEJspServlet.java:246)
    	at org.netbeans.modules.tomcat.tomcat40.runtime.IDEJspServlet.service(IDEJspServlet.java:339)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
    	at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:226)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
    	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    Il retrouve bien LoginForm, mais je ne vois pas ce qui cloche !!
    Merci encore à tous ceux qui peuvent me tuyauter

  6. #6
    Membre habitué
    Profil pro
    ingenieur
    Inscrit en
    Avril 2002
    Messages
    207
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : ingenieur

    Informations forums :
    Inscription : Avril 2002
    Messages : 207
    Points : 128
    Points
    128
    Par défaut
    Voici la page 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
     
     
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
     
    <html>
     
    	<head>
    		<title><bean:message key='index.title'/></title>
    	</head>
     
    	<body>
     
    	<html:errors />
     
    	<html:form action="/login">
     
    		<table width="45%" border="0">
    			<tr>
    				<td><bean:message key='index.username' /></td>
    				<td><html:text property="nom" /></td>
    			</tr>
    			<tr>
    				<td><bean:message key='index.password' /></td>
    				<td><html:password property="pass" /></td>
    			</tr>
    			<tr>
    				<td colspan="2" align="center"><html:submit /></td>
    			</tr>
    		</table>
    	</html:form>
     
    	<a href="addUser.jsp"><bean:message key='addUser'/></a>
     
    	</body>
     
    </html>
    et pour LoginForm

    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
     
     
    package form;
     
    import javax.servlet.http.HttpServletRequest;
     
    import org.apache.struts.action.ActionError;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ActionMessage;
    //import org.apache.struts.action.ActionMessage;
     
    /** 
     * LoginForm.java created by EasyStruts - XsltGen.
     * http://easystruts.sf.net
     * created on 11-18-2003
     * 
     * XDoclet definition:
     * @struts:form name="loginForm"
     */
    public class LoginForm extends ActionForm
    {
    	// --------------------------------------------------------- Instance Variables
    	/** pass property */
    	private String pass;
    	/** nom property */
    	private String nom;
     
    	// --------------------------------------------------------- Methods
     
    	public void reset(ActionMapping mapping, HttpServletRequest request)
    	{
    		nom = null;
    		pass = null;
    	}
     
    	/** 
             * Method validate
             * @param ActionMapping mapping
             * @param HttpServletRequest request
             * @return ActionErrors
             */
    	public ActionErrors validate(
    		ActionMapping mapping,
    		HttpServletRequest request)
    	{
    		ActionErrors ae = new ActionErrors();
     
    		if (nom.length() == 0)
    		{
    			ae.add(nom, new ActionError("error.login"));
    //			ae.add(nom, new ActionMessage("error.login"));
    		}
    		if (pass.length() == 0)
    		{
    			ae.add(nom, new ActionError("error.password"));
    //			ae.add(nom, new ActionMessage("error.password"));
    		}
     
    		return ae;
     
    //		throw new UnsupportedOperationException("Generated method 'validate(...)' not implemented.");
    	}
    	/** 
             * Returns the pass.
             * @return String
             */
    	public String getPass()
    	{
    		return pass;
    	}
    	/** 
             * Set the pass.
             * @param pass The pass to set
             */
    	public void setPass(String pass)
    	{
    		this.pass = pass;
    	}
    	/** 
             * Returns the nom.
             * @return String
             */
    	public String getNom()
    	{
    		return nom;
    	}
    	/** 
             * Set the nom.
             * @param nom The nom to set
             */
    	public void setNom(String nom)
    	{
    		this.nom = nom;
    	}
    }
    Merci.

  7. #7
    Membre habitué
    Profil pro
    ingenieur
    Inscrit en
    Avril 2002
    Messages
    207
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : ingenieur

    Informations forums :
    Inscription : Avril 2002
    Messages : 207
    Points : 128
    Points
    128
    Par défaut
    je précise que LoginForm est dans le répertoire /form/

    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
     
     
        <form-beans>
            <form-bean name="loginForm" type="form.LoginForm">
                <form-property name="pass" type="java.lang.String" />
                <form-property name="nom" type="java.lang.String" />
            </form-bean>
     
            <form-bean name="userForm" type="form.NewUserForm">
                <form-property name="pass" type="java.lang.String" />
                <form-property name="prenom" type="java.lang.String" />
                <form-property name="nom" type="java.lang.String" />
            </form-bean>
     
        </form-beans>
     
        <!-- ========== Global Exception Definitions ============================== -->
        <global-exceptions />
     
        <!-- ========== Global Forward Definitions =============================== -->
        <global-forwards />
     
        <!-- ========== Action Mapping Definitions =============================== -->
        <action-mappings>
            <action
                path="/login"
                input="/index.jsp"
                name="loginForm"
                type="action.LoginAction">
                <forward name="log_failed" path="/index.jsp" />
                <forward name="log_ok" path="/userList.jsp" />
            </action>
     
            <action
                path="/newUser"
                input="/addUser.jsp"
                name="userForm"
                type="action.NewUserAction">
                <forward name="add_failed" path="/addUser.jsp" />
                <forward name="add_ok" path="/index.jsp" />
            </action>
     
        </action-mappings>

  8. #8
    Membre averti
    Inscrit en
    Mars 2004
    Messages
    377
    Détails du profil
    Informations forums :
    Inscription : Mars 2004
    Messages : 377
    Points : 356
    Points
    356
    Par défaut
    Tu n'es pas obligé de définir tes property pour ton formulaire.
    Je te conseille même de les supprimer pour voir.
    Ensuite tu devrais définir un attribute scope à ton action.
    Tente de changer çà, et on verra si cela marche mieux.
    As quel moment a tu les problème de cannot create loginForm ?
    Qu'est ce que tu entends par dans le répertoire /form ???
    Tu veux dire WEB-INF/classes/form ? N'est ce pas ?

  9. #9
    Membre habitué
    Profil pro
    ingenieur
    Inscrit en
    Avril 2002
    Messages
    207
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : ingenieur

    Informations forums :
    Inscription : Avril 2002
    Messages : 207
    Points : 128
    Points
    128
    Par défaut
    Pour le répertoire c'est ça !
    J'essai pour le reste.
    Merci pour ton aide

  10. #10
    Membre averti
    Inscrit en
    Mars 2004
    Messages
    377
    Détails du profil
    Informations forums :
    Inscription : Mars 2004
    Messages : 377
    Points : 356
    Points
    356
    Par défaut
    Essaie de remplacer ton tag form comme suit :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <html:form action="login">
    Tu retires simplement le / de ton login.

  11. #11
    Membre habitué
    Profil pro
    ingenieur
    Inscrit en
    Avril 2002
    Messages
    207
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : ingenieur

    Informations forums :
    Inscription : Avril 2002
    Messages : 207
    Points : 128
    Points
    128
    Par défaut
    En fait une fois que j'ai copié LoginForm dans WEB-INF/classes/form comme me l'a précisé ZeKid et tout a bien fonctionné !!!
    Quel Bordel n'empeche.
    Merci à tous ! 8)

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Débutant] Problème de configuration.
    Par Deb.Java dans le forum Langage
    Réponses: 3
    Dernier message: 07/10/2007, 19h09
  2. [Débutant]Aide pour Configuration ASP.NET
    Par Vlatiska dans le forum ASP.NET
    Réponses: 6
    Dernier message: 15/03/2007, 13h34
  3. [Débutant(e)] [log4j] configuration
    Par dosy07 dans le forum Logging
    Réponses: 1
    Dernier message: 28/11/2005, 08h41
  4. [Débutant] Fichier de configuration
    Par Xavinou dans le forum Eclipse Java
    Réponses: 4
    Dernier message: 26/09/2005, 23h02
  5. [Débutant(e)][Jcreator]Configuration
    Par tachag dans le forum Environnement de Développement Intégré (EDI)
    Réponses: 6
    Dernier message: 02/08/2005, 18h51

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