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 :

Error creating form bean of class presentation.str.RolesForm


Sujet :

Struts 1 Java

  1. #1
    Débutant
    Inscrit en
    Septembre 2007
    Messages
    372
    Détails du profil
    Informations forums :
    Inscription : Septembre 2007
    Messages : 372
    Points : 86
    Points
    86
    Par défaut Error creating form bean of class presentation.str.RolesForm
    Bonjour, je viens de créer un formbean comme suit :

    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
    package presentation.str;
     
    import java.util.List;
    import java.util.Vector;
     
    import javax.servlet.http.HttpServletRequest;
    import ma.corporate.planning.metier.Role;
     
    import org.apache.struts.action.ActionError;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
     
    public class RolesForm extends ActionForm  {
     
    	private List<Role> roles = new Vector<Role>();
    	private String action = "";
    	private int idRole;
    	private Role role = new Role();
     
    	public List<Role> getRoles() {
    		return roles;
    	}
    	public void setRoles(List<Role> roles) {
    		this.roles = roles;
    	}
    	public String getAction() {
    		return action;
    	}
    	public void setAction(String action) {
    		this.action = action;
    	}
    	public int getIdRole() {
    		return idRole;
    	}
    	public void setIdRole(int idRole) {
    		this.idRole = idRole;
    	}
    	public Role getRole() {
    		return role;
    	}
    	public void setRole(Role role) {
    		this.role = role;
    	}
    	public ActionErrors validate(ActionMapping arg0, HttpServletRequest arg1) {
    		ActionErrors errors = new ActionErrors();
     
    		if ((getRole().getNomRole()== null) || ((getRole().getNomRole().length() < 1)))
    		errors.add("nomRole", new ActionError("error.nomrole.vide"));
     
    		return errors;
    	}
     
    }
    et mon fichier struts-config.xml :
    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
    <?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE struts-config PUBLIC
              "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
              "http://struts.apache.org/dtds/struts-config_1_2.dtd">
     
    <struts-config>
     <form-beans>
     	<form-bean name="cfc" type="presentation.str.ClientsForm"/>
     	<form-bean name="cfs" type="presentation.str.ServicesForm"/>
     	<form-bean name="cfr" type="presentation.str.RolesForm"/>
     </form-beans>
     <global-forwards>
     
      <forward name="VueClient" path="client.page"/>
      <forward name="addClient" path="ajoutclient.page"/>
      <forward name="editClient" path="editclient.page"/>
     
      <forward name="VueService" path="service.page"/>
      <forward name="addService" path="ajoutservice.page"/>
      <forward name="editService" path="editservice.page"/>
     
      <forward name="VueRole" path="role.page"/>
      <forward name="addRole" path="ajoutrole.page"/>
      <forward name="editRole" path="editrole.page"/>
     
     </global-forwards>
     <action-mappings>
     
    	 <action 
    	 path="/gestClient" 
    	 name="cfc" 
    	 type="presentation.str.ClientsAction" 
    	 scope="session"
    	 validate="false">	 
    	</action>	
     
    	<action 
    	 path="/gestService" 
    	 name="cfs" 
    	 type="presentation.str.ServicesAction" 
    	 scope="session"
    	 validate="false">	 
    	</action>	
     
    	<action 
    	 path="/gestRole" 
    	 name="cfr" 
    	 type="presentation.str.RolesAction" 
    	 scope="session"
    	 validate="false">	 
    	</action>			  
     
     </action-mappings>
     
     <message-resources parameter="ApplicationResources"/>   
     <!-- Tiles Configuration -->
    <plug-in className="org.apache.struts.tiles.TilesPlugin">
      <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml"/>
    </plug-in>
     
    </struts-config>
    il m'affiche les erreurs suivantes :
    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
    16:54:09,484 ERROR RequestUtils:304 - Error creating form bean of class presentation.str.RolesForm
    java.lang.NullPointerException
    	at org.apache.struts.config.FormBeanConfig.createActionForm(FormBeanConfig.java:212)
    	at org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:292)
    	at org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:191)
    	at org.apache.struts.action.RequestProcessor.processActionForm(RequestProcessor.java:319)
    	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:202)
    	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
    	at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
    	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
    	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    	at java.lang.Thread.run(Unknown Source)
    16:54:09,500 ERROR RequestProcessor:284 - No action instance for path /gestRole could be created
    java.lang.ClassNotFoundException: presentation.str.RolesAction
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1352)
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
    	at org.apache.struts.util.RequestUtils.applicationClass(RequestUtils.java:117)
    	at org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:143)
    	at org.apache.struts.action.RequestProcessor.processActionCreate(RequestProcessor.java:280)
    	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:218)
    	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
    	at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
    	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
    	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    	at java.lang.Thread.run(Unknown Source)
    vous savez d'ou l'erreur ?

  2. #2
    Membre régulier
    Inscrit en
    Juillet 2002
    Messages
    225
    Détails du profil
    Informations forums :
    Inscription : Juillet 2002
    Messages : 225
    Points : 85
    Points
    85
    Par défaut
    Il parrait qu'il trouve pas ta classe action : presentation.str.RolesAction

    assure toi de l'orthographe et le chemin complet de cette classe

  3. #3
    Débutant
    Inscrit en
    Septembre 2007
    Messages
    372
    Détails du profil
    Informations forums :
    Inscription : Septembre 2007
    Messages : 372
    Points : 86
    Points
    86
    Par défaut
    j'ai vérifié l'orthographe,

    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
    package presentation.str;
     
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
     
    import ma.corporate.planning.metier.GestRole;
    import ma.corporate.planning.metier.GestService;
    import ma.corporate.planning.metier.Role;
    import ma.corporate.planning.metier.Service;
     
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionError;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ActionMessage;
    import org.apache.struts.action.ActionMessages;
     
    public class RolesAction extends Action{
     
    	@Override
    	public ActionForward execute(ActionMapping map, ActionForm form,
    			HttpServletRequest request, HttpServletResponse response)
    			throws Exception {
     
    		RolesForm rf = (RolesForm)form;
    		GestRole gr= new GestRole();
     
    		if(rf.getAction().equals("")){
    			rf.setRoles(gr.getAllRole());
    		}
    		else if(rf.getAction().equals("Editer")){
     
    			Long idr=new Long(rf.getIdRole());
    			rf.setRole(gr.getRole(idr));
    			return map.findForward("editRole");
     
    		}
     
    		else if(rf.getAction().equals("Supprimer")){
     
    			Long idr=new Long(rf.getIdRole());
    			gr.suppRole(idr);
    			rf.setRoles(gr.getAllRole());
    			return map.findForward("VueRole");
     
     
    		}
    else if(rf.getAction().equals("Valider")){
     
     ActionMessages errors = form.validate(map,request);
         ActionError newError = null;
     
        ActionMessages messages = new ActionMessages();
        ActionMessage newMessage = null;
    	if ( !errors.isEmpty() )
    	{
    		this.saveErrors(request,errors);
    		return map.findForward("addRole");
    	}
    	else
    	{
    		Boolean t=  gr.addRole(rf.getRole().getNomRole());
     
    		if(t) {
    			newMessage = new ActionMessage("message.ajout.role.succes");
    			messages.add("msgajoutservice", newMessage);
     
    			this.saveMessages(request, messages); 
    			rf.setRoles(gr.getAllRole());
    			return map.findForward("VueRole");
    		}
    		else {
            	newError = new ActionError("errors.doublons.role.Database");
            	errors.add(ActionErrors.GLOBAL_ERROR, newError);
     
            	saveErrors(request, errors);
            	return  map.findForward("addRole");
    		}
    	}
     
    }	
    else if(rf.getAction().equals("Modifier")){	
     
    	 ActionMessages errors = form.validate(map,request);
         ActionError newError = null;
     
        ActionMessages messages = new ActionMessages();
        ActionMessage newMessage = null;
    	if ( !errors.isEmpty() )
    	{
    		this.saveErrors(request,errors);
    		return map.findForward("editRole");
    	}
    	else
    	{
    		Boolean t= gr.updateR(rf.getRole()); 
    		if(t) {
    			newMessage = new ActionMessage("message.modif.role.succes");
    			messages.add("msgmodifservice", newMessage);
     
    			this.saveMessages(request, messages); 
    			rf.setRoles(gr.getAllRole());
    			return map.findForward("VueRole");
    		}
    		else {
            	newError = new ActionError("errors.doublons.role.Database");
            	errors.add(ActionErrors.GLOBAL_ERROR, newError);
     
            	saveErrors(request, errors);
            	return  map.findForward("editRole");
    		}
    	}
    }
    else if(rf.getAction().equals("Ajouter")){
    			rf.setRole(new Role());
    			return map.findForward("addRole");
    		}
    		return map.findForward("VueRole");
    	}
    }

  4. #4
    Débutant
    Inscrit en
    Septembre 2007
    Messages
    372
    Détails du profil
    Informations forums :
    Inscription : Septembre 2007
    Messages : 372
    Points : 86
    Points
    86
    Par défaut
    apparemment les fichiers .class ne sont pas crée

  5. #5
    Débutant
    Inscrit en
    Septembre 2007
    Messages
    372
    Détails du profil
    Informations forums :
    Inscription : Septembre 2007
    Messages : 372
    Points : 86
    Points
    86
    Par défaut
    Est ce que ce problème est lié a mon IDE ou quoi exactement sachant que j'ai deja crée des form bean et des actions sans problème ?

  6. #6
    Membre régulier
    Profil pro
    Inscrit en
    Novembre 2007
    Messages
    89
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2007
    Messages : 89
    Points : 102
    Points
    102
    Par défaut
    sauf erreur
    se serait pas
    public class RolesAction extends ActionForm {
    au lieu de
    public class RolesAction extends Action{

  7. #7
    Membre régulier
    Inscrit en
    Juillet 2002
    Messages
    225
    Détails du profil
    Informations forums :
    Inscription : Juillet 2002
    Messages : 225
    Points : 85
    Points
    85
    Par défaut
    Citation Envoyé par newmar Voir le message
    apparemment les fichiers .class ne sont pas crée
    Essai de mettre un constructeur dans ta classe Action .

    Autre possibilité :

    regarde ton web.xml :

    les lignes :


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    <filter-mapping>
    <filter-name>...</filter-name>
    <url-pattern>*.do</url-pattern>
    </filter-mapping>
    c'est quoi ton url-pattern ?



    si c'est .do


    essaies en changeant tous les paths dans tes actions dans struts config comme ça :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    <action 
    path="/gestRole" 
    ..>
    deviens
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
     
    path="/gestRole.do"

Discussions similaires

  1. Réponses: 4
    Dernier message: 21/03/2010, 17h29
  2. Error creating form: Ancestor
    Par BuzzLeclaire dans le forum Langage
    Réponses: 9
    Dernier message: 01/10/2009, 14h16
  3. Réponses: 1
    Dernier message: 15/04/2009, 21h06
  4. Réponses: 4
    Dernier message: 19/10/2008, 23h31
  5. [Débutant] Error creating form bean
    Par dark&wise dans le forum Struts 1
    Réponses: 2
    Dernier message: 16/08/2007, 09h01

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